In a document, I have about 25 DIVs which contain forms with various names. The DIVs all have the same class name and look like this:
<div class="swoop" style="display:none">
<form name="myFormXYZ" method="post">
<input name="caption" type="hidden" value="19">
</form>
</div>
I want to write jQuery code which will check all DIVs with the class of "swoop" and if any DIVs contain an input field named "caption" which has a value of x, then the display property of those DIVs should be set to "block". x will be an integer between 1 and 1000.
So far I have come up with this:
$('.swoop').each(function() {
var capt = $( ? ? ? ).attr('value()');
if (capt == x) {$(this).css.(display','block')}
});
Can the jQuery function even iterate through the DIVs whose display is set to none?
display: noneis not rendered, but it is still in the DOM. So yes,$('.swoop')will select all elements with class.swoop.