By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,376 Members | 3,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,376 IT Pros & Developers. It's quick & easy.

Friends I am new here I have a question code of JQ

P: 1
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Page Title</title>
  4. <script src="https://code.jquery.com/jquery-3.1.1.js"></script>
  5. </head>
  6. <body>
  7. <p value="223">JQuery is </p>
  8.  
  9. <!--!The code prints an integral number like 4! But I'm actually a decimal number 4.4-->
  10.  
  11. <p value="4.4">JQuery is </p> 
  12. <div></div>
  13.  
  14. </body>
  15.  
  16.  
  17. <script type="text/javascript">
  18.  
  19. $( document ).ready(function() {
  20. var arr=new Array(); $('p').each(function() { 
  21. $(this).click(function() {
  22. arr.push($(this).attr("value"));
  23.  
  24. var total = 0;
  25. $.each(arr,function(i) {
  26. total += arr[i] << 0;
  27.  
  28. $("div").html(total);
  29. });
  30. });
  31. });
  32. });
  33.  
  34. </script>
  35.  
  36. </html>
Mar 11 '17 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
What is your question?
Mar 13 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.