skip to Main Content

How to combine jquery selector with 'this'

I want to combine these two statements into one. $("#thing1, #thing2").toggleClass('myClass'); $(this).toggleClass('myClass'); Instincts told me this might work: $("#thing1, #thing2", this).toggleClass('myClass'); but after some research, I discovered it is equivalent to this: $(this).find("#thing1, #thing2").toggleClass('myClass'); I can't find anything in the…

VIEW QUESTION

toggleClass doesn't work with display:block – Jquery

I have 4 divs which have style="display: none" property and when I try to change the property to display: block through toggleClass it doesn't works. JS: $(document).ready(function () { $("#add_client").click(function () { $("#inputs").toggleClass("shown"); }); $("#show_clients").click(function () { $("#show_information").toggleClass("shown"); }); $("#show_free_rooms").click(function…

VIEW QUESTION

jquery second click no works when add class and remove class

jQuery(document).ready(function() { if(jQuery("#init").hasClass("show_box")) { jQuery("#init").click(function() { jQuery("#box").show(1000); jQuery("#init").removeClass("show_box"); jQuery("#init").addClass("hide_box"); }); } }); jQuery(document).ready(function() { if(jQuery("#init").hasClass("hide_box")) { alert("ok"); jQuery("#box").hide(1000); } }); <div id="box" style="position:relative;width:100px;height:100px;background-color:red;display:none";></div> <span id="init" class="show_box"> Box Action </span> As you can see the jquery script show div with id…

VIEW QUESTION
Back To Top
Search