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]')