bytearray - jquery association array -
need little i'm sure easy jquery
i have following repeating markup (several list items)
<li> <div class="answer"> <p><select class="dropdown"> ..options.. </select></p> </div> <div class="commentbox"> ..content.. </div> </li>
depending on value of selected option when pages loads, "commentbox" shown/hidden.
i have tried following jquery
var dd = $('.dropdown'); var com = $('.commentbox'); dd.each(dd, function(n, val){ if($(this).val() == 'whatever'){ com[n].setstyle('display', 'none'); } });
i error "b.apply not function"
so in head, how should work - if it's first select dropdown, show/hide first "commentbox" div. if it's second dropdown show/hide second "commentbox" div. , on.
i think have got in mess trying various jquery techniques sure there dozens of possibilities here. thanks
your problem you're passing (first) parameter each
.
each
takes set first parameter when called statically.
in other words:
$.each(dd, function() { ... });
or
dd.each(function() { ... });
note can make code clearer changing to
$(this).closest('li').find('.commentbox').hide();
Comments
Post a Comment