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

How to delete a certain style in css with jquery

藏色散人
Release: 2023-01-03 09:26:03
Original
3695 people have browsed it

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.

How to delete a certain style in css with jquery

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.

How to delete a certain style in css with jquery

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.

How to delete a certain style in css with 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.

How to delete a certain style in css with jquery

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"]

How to delete a certain style in css with jquery

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.

How to delete a certain style in css with jquery

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.

How to delete a certain style in css with jquery

Open the test.html file in the browser and click the button to see the effect.

How to delete a certain style in css with jquery

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!

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