Sum of values in jquery and corresponding numerical styles based on remainder

Source: Internet
Author: User

jquery content

<script type= "Text/javascript" >

$ (function () {

var num = 0;

$ (". Box ol li:eq (0)"). Click (function () {


$ (": Text"). each (function () {

num + = parsefloat ($ (this). Val ());

});

alert (num);

});

$ (". Box ol Li:eq (1)"). Click (function () {


var num = 0;
$ (": Text"). each (function () {

num + = parsefloat ($ (this). Val ());

if (parseint (this). val ()) = = parseint (num% 9)) {


$ (this). CSS ("Background", "Red");
}
});

});

});

</script>

HTML content

<body style= "FONT-SIZE:12PX;" >
<div class= "box" >
Please write JavaScript code to complete the following function requirements: <br/>
<ol>
<li>
Calculates the sum of the numbers in the following text box
<input type= "button" value= "point I perform calculation"/>
</li>
<li>
Point I will the sum of all the numbers in the text box, the remainder for 9, the text box with the number equal to the remainder of the foreground color changed to red
<input type= "button" value= "point I perform calculation"/>
</li>
</ol>
</div>
<div id= "Mybox" class= "box" >
<input type= "Text" value= "1"/>
<input type= "Text" value= "2"/>
<input type= "Text" value= "3"/>
<input type= "Text" value= "4"/>
<input type= "Text" value= "5"/>
<input type= "Text" value= "6"/>
<input type= "Text" value= "7"/>
<input type= "Text" value= "8"/>
<input type= "Text" value= "9"/>
</div>
</body>

Sum of values in jquery and corresponding numerical styles based on remainder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.