admin管理员组文章数量:1394990
In my JSP I have 3 div
elements out of which 2 elements has class
"shadow".
<div name="master" class="shadow">
..................................
</div>
<div name="child1" class="shadow">
..................................
</div>
<div name="child2" class="normalshadow">
..................................
</div>
Now in my java script, I want to find all the div elements which has class shadow and remove that class from those div elements. How can i do that ?
In my JSP I have 3 div
elements out of which 2 elements has class
"shadow".
<div name="master" class="shadow">
..................................
</div>
<div name="child1" class="shadow">
..................................
</div>
<div name="child2" class="normalshadow">
..................................
</div>
Now in my java script, I want to find all the div elements which has class shadow and remove that class from those div elements. How can i do that ?
Share Improve this question asked May 29, 2017 at 10:25 sreeharisreehari 1896 silver badges16 bronze badges 2-
3
$('div.shadow')
– btlm Commented May 29, 2017 at 10:27 - 1 Possible duplicate of How to remove class from all elements jquery – Sandman Commented May 29, 2017 at 10:42
3 Answers
Reset to default 5Find all div with class shadow
using .
$(".shadow")
and remove class use .removeClass()
function please find below snippet for more info
$('div.shadow').removeClass('shadow');
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div name="master" class="shadow">
..................................
</div>
<div name="child1" class="shadow">
..................................
</div>
<div name="child2" class="normalshadow">
..................................
</div>
$('div[class="shadow"]').removeClass("shadow")
if you want both <div class="shadow"></div>
and <div class="normalshadow">
to be selected you can do this $('div[class*=shadow]')
本文标签: javascriptHow to find all div elements with specific class using jqueryStack Overflow
版权声明:本文标题:javascript - How to find all div elements with specific class using jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744107904a2591151.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论