Convert jquery element to html element

后端 未结 2 1188
忘掉有多难
忘掉有多难 2020-12-24 04:34

I have a jQuery element but I have to send it to a function that only accepts HTML elements. How can I convert the jQuery element to an HTML element?

相关标签:
2条回答
  • 2020-12-24 05:04

    $("#foo")[0] will get you an HTML element. Using brackets is a tiny bit faster than using .get() but not something you'll likely notice unless you are doing it millions of times.

    0 讨论(0)
  • 2020-12-24 05:10

    Try myJQueryElement.get(0) or myJQueryElement[0]. (get() is most useful when you need negative indices, for example, as described in the documentation for get().)

    0 讨论(0)
提交回复
热议问题