This is probably a pretty pointless question but I reckon it would be useful for many of us.
In this case’s scenario, I would like to be able to hide a textbox and its label all in one go, without having to select both element and hiding them individually.
<label for="a">some text:</label>
<input type="text" class="text" id="a" />
So, for the above case, would it be possible to use a simple jQuery command to hide them both together?
You could do this
http://jsfiddle.net/jasongennaro/dYFMU/
[ ]selects theattribute. In this case we are targeting aforattribute that equalsa.At the same time, we use a
,to make another selection, theinputwith anid=a.EDIT
Also, if you needed to do this for multiple
labelsandinputsyou could put thelabelandidin an array as follows:js
http://jsfiddle.net/jasongennaro/dYFMU/1/