jquery - Remove specific class when button/dropdown click -


i want remove specific class ("help-text"). when user click on button specific class removed.

here code

<div class="dropdown dropdown-lg">     <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">         <img src="img/find-match.png"/>         <span class="help-text">click here</span>     </button> </div>  <script> jquery(document).click(function (e) {     if (!jquery(e.target).hasclass('dropdown-lg')) {         jquery('.dropdown-lg').removeclass('help-text');     } }); </script> 

kindly advice me solution.

the span help-text, inside button. can use,

$(e.target).find('.help-text').removeclass('help-text') 

or

$('.help-text',e.target).removeclass('help-text') 

also, instead of handling click on document suggest,,

$('button.dropdown-toggle').click(... 

fiddle

$('button.dropdown-toggle').click(function(){     $(this).find('.help-text').toggleclass('help-text') }); 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -