Home > Web Front-end > JS Tutorial > body text

jquery implements textarea input character control (imitation Weibo input control characters)_jquery

WBOY
Release: 2016-05-16 17:35:06
Original
1010 people have browsed it

The rendering is as follows:
jquery implements textarea input character control (imitation Weibo input control characters)_jquery
JQUERY code:

Copy code The code is as follows:

var text=$(".release textarea").val();//Get the value of the input box
var counter=text.length; //Get the value of the input box
$(" #numtj em").text(500-counter);
$(document).keyup(function() {
var text=$(".release textarea").val();
var counter=text.length;
$("#numtj em").text(500-counter);
if(counter>500){ //If the number of words is greater than 500
$(".public" ).addClass("public01").attr("disabled","true") //Publish button is disabled
}
else{
$(".public").removeClass("public01") .removeAttr("disabled") //Publish button enabled
}
});

Word count style:
Copy the code The code is as follows:

#numtj em {
font-weight: 700;
font-size: 22px;
font- style: italic;
font-family: Constantia, Georgia;
color:#C00;
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template