JQuery addClass, removeClass and toggleClass methods, jquerytoggleclass
The addClass, removeClass, and toggleClass methods of jQuery can replace the first two methods in some cases.
The first method addClass adds a class to the element.
The second method, removeClass, removes a class.
The third method toggleClass is a mutex class.
<input id="Text1" type="text" />
Create a style. When the text box is focused, the border of the text box is highlighted and widened. When blur is used, the original style is restored.
.textbborder { border:solid; border-color:red; border-width:3px; }
You can use the jQuery code to implement the following:
In the above Code, Insus. NET is implemented using addClass and removeClass methods. If you use the toggleClass method, refer to the following code:
$ (Function () {// $ ('# Text1 '). focus (function () {// $ (this ). addClass ('textbborder'); //}); // $ ('# text1 '). blur (function () {// $ (this ). removeClass ('textbborder'); //}); $ ('# text1 '). focus (function () {$ (this ). toggleClass ('textbborder') ;}; $ ('# text1 '). blur (function () {$ (this ). toggleClass ('textbborder ');});})Source Code
Demo: