Home >Web Front-end >JS Tutorial >How to remove the same level class in Jquery
Jquery method to remove the same level class: 1. Use the "$(".Element class name")" statement to obtain the object according to the specified class value; 2. Use the removeClass() method to remove the class of the element , the syntax is "element object.removeClass('element class name')".
The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.
How to remove the same class with Jquery
1. Open the html editor and create a new html file. Find
on the html code page and create a new<div class="remark">今晚要去吃大餐</div>
Create a new click button behind
<input type="button" value="移除class" onclick="reClass()">
Set class style. Set a style for remark with a font size of 28px and a color of red.
<style> .remark{ font-size: 28px;color: red; } </style>
The code is as follows:
2. Introduce the jQuery library. Introduce the jquery library after the
<script type="text/javascript" src="jquery.js"></script>
Create a click event. Create a new <script> tag after the <script> tag, and create a click to remove class event in this new tag. </script>
<script type="text/javascript"> function reClass(){ $(".remark").removeClass('remark') } </script>
After saving, open it with a browser, click the remove class button, and find that the font size and color in
Related video tutorial recommendations: jQuery video tutorial
The above is the detailed content of How to remove the same level class in Jquery. For more information, please follow other related articles on the PHP Chinese website!