Jquery method to add classname to an element: 1. Use the "$(element)" statement to match the element object; 2. Use the addClass() method to add a classname to the element. The syntax is "element object.addClass( "classname to add")".
The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.
How to add a classname to an element in jquery
1. Create a new html page, and then add a text with the text
html code:
<div id="add">点击按钮添加class</div> <input type="button" value="添加class" onclick="addBtn()" />
Add the style of the class class. Create a