jquery Tutorial-jquery Get the number of tags size () function usage, and the size () method returns the number of elements that are matched by the Jquery selector.
Grammar
$ (selector). Size ()
The number of elements in the JQuery object. The return value of this function is associated with the JQuery object's 'The length ' property is consistent.
Purpose: Can be used to count the number of items in a page. For example, to statistical language scores of less than 100 records, you can give less than 100 of the field assigned to <font class= "xx" >oo</font>. The number of this label is counted as the result.
<Script language="Javascript"Type="Text/javascript"Src="Jquery.min.js"></Script>
<Script language="Javascript"Type="Text/javascript">
$ (document). Ready (function(){
$(‘#sbt‘). Click (function(){
VarI=$(‘Div‘). Size ();//Get the number of div tags
VarJ=$(‘. mm‘). Size ();//Get the number of font labels class mm
$(‘#myspan‘). HTML (‘<strong><font Color=red> altogether has‘+I+‘A div tag altogether has‘+J+‘A font label </font></strong>‘);
})
})
</Script>
<Div>Div1</Div><br>
<Div>Div2</Div><br>
<Div>Div3</Div><br>
<Div>Div4</Div><br>
<Font class="Mm">Mm1</Font><br>
<Font class="Mm">mm2</Font><br>
<Font class="Mm">mm2</Font><br>
<Span ID= "myspan" ></span><br>
<input Type=submit " value=" calculate " id= "sbt"/>
Jquery Tutorial-jquery Get the number of tags size () function usage