If conditional not working in jQuery each function -
here html:
<div> <li> <a href="#">link</a> </li> <li> <a href="#">link 2</a> </li> <li> <a href="#">link 3</a> </li> </div>
this jquery code working fine:
$("div li").each(function() { $('a', this).wrapinner("<span></span>"); });
however breaks code , nil happens @ all.
$("div li").each(function() { $('a', this).wrapinner("<span></span>"); if $('span', this).height() > 10 { $(this).addclass('newclass'); } });
what need happen after span inserted link, need span's height measured , if on 10px containing li have class of newclass applied it.
if ($('span', this).height() > 10) { $(this).addclass('newclass'); }
you need have if statement status wrapped in parenthesis.
jquery
No comments:
Post a Comment