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