Using jQuery instead of document.getElement

I would like to use

$("#fooid")

instead

document.getElementById("fooid")

because I get the id with #in front of it. Although you can easily remove it, there is quite a bit of confusion between when I use the jQuery selector and when I use my own DOM calls. In particular, this is called inside a diagram, which appears to be expecting a native DOM object. By giving it this extended jQuery object, it suffocates and turns purple.

Is there a way I can get jQuery to “play well” and pretend to give or return its own object instead?

+3
source share
2 answers

get DOM:

$("#fooid").get(0);

:

$("#fooid")[0];
+5
+1

Source: https://habr.com/ru/post/1768472/


All Articles