admin管理员组文章数量:1321823
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?
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?
Share Improve this question asked Oct 13, 2010 at 20:42 CharlyCharly 531 silver badge3 bronze badges2 Answers
Reset to default 8You can turn a normal DOM element into a jQuery selection by wrapping it in $()
:
var element = document.elementFromPoint(x, y);
$(element).offset();
You need to wrap it into the jQuery constructor function, which returns a jQuery object
.
jQuery(element).offset();
or shortcut method
$(element).offset();
http://api.jquery./jQuery/
本文标签: javascriptUsing element object with jQuery methodStack Overflow
版权声明:本文标题:javascript - Using element object with jQuery method? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742103989a2420935.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论