javascript - jquery addClass to element if css has style -


please have @ following question , answer, seccond answer (with many upvotes) jquery: how check if element has css class/style

looks this:

if ($('#yourelement').css('position') == 'absolute') {     // true } 

so awesome like

if ($('#yourelement').css('position') == 'absolute') {     $(this).addclass('xxx'); } 

so element id "yourelement" gets class added

what easyest way that

you way:

$('#yourelement').addclass(function(index, currentclass) {     return $(this).css('position') == 'absolute' ? 'xxx' : ''; }); 

for more information on syntax take @ api .addclass().


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -