The jquery method to delete a CSS style: first create a new html file; then introduce the jquery.min.js library file; then use style to define the style of the div in the div tag; finally, use the created delbg function Just delete a certain css style.
The operating environment of this tutorial: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.
jquery removes an attribute in style:
Create a new html file, named test.html, to explain jquery's removal of an attribute in style.
In the test.html file, introduce the jquery.min.js library file and successfully load the file before you can use the methods in jquery.
In the test.html file, use the div tag to create a module and set its id to testdiv, which is mainly used to obtain the div object through the id below.
In the div tag, use style to define the style of the div, use css to set the width of the div to 100px, the height to 100px, the border to 1px solid pink border, and the background The color is red. [Recommended: "css video tutorial"]
In the test.html file, use the button tag to create a button and bind onclick to the button button Click event, when the button is clicked, the delbg() function is executed.
In the js tag, create the delbg() function. Within the function, obtain the div object through the id of the div, and use the css() method to set the background attribute to empty. It is possible to remove the background color.
Open the test.html file in the browser and click the button to see the effect.
The above is the detailed content of How to delete a certain style in css with jquery. For more information, please follow other related articles on the PHP Chinese website!