Ok, so I have a div with a few elements in it and I want to toggle them all, but in my jquery code I have to call all these elements. How can I select them instead of call all of the elements ids? I have to toggle something like this:
<div id="divtotoggle">
<input type="text" id="textinput" />
<input type="button" id="button />
<div id="feedback"></div>
</div>
If you only want to toggle the immediate children of your <div>
element, you can use the aptly-named children() method to match them:
$("#divtotoggle").children().toggle();
If you want to toggle all the descendant elements (which does not make much sense to begin with, as others rightfuly pointed out in the comments below), you can use an All selector:
$("#divtotoggle *").toggle();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With