jquery - Find .offset of each element with X class -


i'd know how can .offset of multiple elements variables, idea this:

var position = $(this).offset().top; $(".number").text(position); 

and way, every element .number class display own particular offset, problem isn't working, it's undefined, , can't seem figure out how it.

any appreciated.

thanks in advance!

you can use function parameter of text() method:

$(".number").text(function(){    return $(this).offset().top; // or this.offsettop (relative parent node) }); 

-jsfiddle-


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -