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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -