Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using element object with jQuery method?

I just started using jQuery. Now I want to use an jQuery method with an element object.

var element = document.elementFromPoint(x, y);
element.offset();

Of course this doesn't work because the variable element is not a jQuery selector, so the error message I get in Firebug is "element.offset is not a function". Is there any general method I could use this element object with an jQuery selector?

like image 797
Charly Avatar asked Oct 13 '10 20:10

Charly


1 Answers

You can turn a normal DOM element into a jQuery selection by wrapping it in $():

var element = document.elementFromPoint(x, y);
$(element).offset();
like image 68
lonesomeday Avatar answered Sep 21 '22 14:09

lonesomeday