html - Jquery Select element before and Element after remove/add class -
i'm trying remove 2 classes div content:
<div class="content"> <div class="1 hide">class1</div> <div class="2">class2</div> <div class="3 hide">class3</div> </div> <div class="content"> <div class="1 hide">class1</div> <div class="2">class2</div> <div class="3 hide">class3</div> </div> <div class="content"> <div class="1 hide">class1</div> <div class="2">class2</div> <div class="3 hide">class3</div> </div> <script> $( ".content" ).click(function() { remove classes hide class 1 , 3 in content div if clicked on div leave other content divs class 1 , 3 hidden }); </script>
whats best way can't figure out how :(
thanks helping!
you need utilize context bases selector like
class="snippet-code-js lang-js prettyprint-override">$(".content").click(function () { $(this).find('.hide').removeclass('hide') });
class="snippet-code-css lang-css prettyprint-override">.hide { display: none; }
class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="content"> <div class="1 hide">class1</div> <div class="2">class2</div> <div class="3 hide">class3</div> </div> <div class="content"> <div class="1 hide">class1</div> <div class="2">class2</div> <div class="3 hide">class3</div> </div> <div class="content"> <div class="1 hide">class1</div> <div class="2">class2</div> <div class="3 hide">class3</div> </div>
jquery html class
No comments:
Post a Comment