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

How to modify, add and delete class styles in js_javascript skills

WBOY
Release: 2016-05-16 16:18:50
Original
1375 people have browsed it

The example in this article describes the method of modifying, adding and deleting class styles in js. Share it with everyone for your reference. The specific analysis is as follows:

A relatively common js front-end function, the corresponding function can be achieved by modifying the className of the tag.

The specific code is as follows:

Copy code The code is as follows:









                             
                                                                                                                               .                                                                                          
JS implements modification, addition, and deletion of class styles
goods code
goods item number
Specification name
Select All


<script> $('.goods_sale_property').click(function(){//Click on a separate a tag to add class<p> If($(this).hasClass('goods_sale_property_checked')){<br>           $(this).removeClass('goods_sale_property_checked');<br> }else{<br>           $(this).addClass('goods_sale_property_checked');<br> }<br> });<br> function selectAll(){//Select all and add class<br> $('.goods_sale_property').each(function(i){<br>           $(this).addClass('goods_sale_property_checked');<br> }); <br> }<br> function selectNotAll(){//Select all and delete class<br> $('.goods_sale_property').each(function(i){<br> $(this).removeClass('goods_sale_property_checked');<br> }); <br> }<br> </script>

I hope this article will be helpful to everyone’s JavaScript programming design.
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