shahriar Posted April 9, 2020 Share Posted April 9, 2020 <div class="price">4.21</div> <div class="price">3.82</div> <script> var sum = 1; $('.price').each(function() { sum *= parseFloat($(this).text()); }); document.write(sum); </script> Can anyone convert this into Java? read "price class" as anywhere in the template and multiply elements inside them. Link to comment Share on other sites More sharing options...
JMRKER Posted April 13, 2020 Share Posted April 13, 2020 As soon as you execute the "document.write()" statement, the program reloads the page and you lose all earlier calculations and references. Consider writing the results to another element and use ID values to help with references. BTW, welcome to the forums. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now