jquery - Concatenate pseudo & class variable -


i'm using viewport selectors jquery plugin, , trying perform same task on few elements:

$('#something').each(function(){     var current = $(this);     if ($(this + ':in-viewport')){         console.log(current.attr('id'));     } }); 

am doing horribly wrong? error console spitting out:

uncaught error: syntax error, unrecognized expression: [object htmldivelement]:in-viewport

you're concatenating this object :in-viewport string, , object being converted tostring , result [object htmldivelement]:in-viewport, illegal jquery selector.

i think you're looking this:

$('#something').each(function(){     var current = $(this);     if ($(this).is(':in-viewport')) {         console.log(current.attr('id'));     } }); 

or in better version of specific code:

$('#something:in-viewport').each(function(){     console.log($(this).attr('id')); }); 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -