JQuery implements the method of counting the number of input texts, and jquery implements the number of texts
This example describes how jQuery counts the number of input texts. Share it with you for your reference. The details are as follows:
JQuery statistics on the number of input texts can be used in statistics on the number of reply words, the length of the title word tip, increase friendliness to improve user experience. The Code is as follows:
Copy codeThe Code is as follows: <Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> jQuery count </title>
<Script type = "text/javascript" src = "js/jquery. js"> </script>
</Head>
<Body>
<Ul>
<Li>
<Span> News Title: </span>
<Span> <input id = "news_title" name = "news_title" type = "text" size = "60" onkeyup = "title_len ();" onclick = "title_len (); "maxlength =" 80 "/>
& Lt; span id = "titlelen" & gt; 0/80 & lt;/span & gt;
</Li>
</Ul>
</Body>
<Script language = "javascript" type = "text/javascript">
Function title_len (){
Var value = $ ('# news_title'). val (). length;
If (value = 80 ){
Var string = "<span style = \" color: # FF0000 \ ">" + value + "/80 </span> ";
} Else {
Var string = "<span style = \" color: # FF0000 \ ">" + value + "</span>/80 ";
}
Certificate ('effectitlelen'}.html (string );
}
</Script>
</Html>
I hope this article will help you with jQuery programming.