Radek Radek - 6 months ago 17
jQuery Question

How to get a DOM node, jQuery node or selector pointing to the element?

I want to use ._get_type ( node ) function from jsTree plugin types The documentation says


Get the type of a node.
(mixed node)
This can be a DOM node, jQuery node or selector pointing to the element.


I do not know what to supply as a
node
. I use hotkeys plugin and on enter press I want to display the type of that node.

I hope this is the relevant html code where
rel="testsuite"
specifies the node type.

<li class="jstree-closed" runurl="&lt;a class='non-html' href=&quot;http://10.0.0.50:4567/run2?run=login&amp;group=basics&quot;&gt;run&lt;/a&gt;" rel="testsuite" run="&lt;button class=&quot;square_button button_background&quot; type=&quot;button&quot; onclick=&quot;run_through_ajax('login','basics')&quot; &gt; run &lt;/button&gt;">


Is there any tutorial that can help me to understand anything I need to know my own questions like that in the future? Note that I cannot read jsTree source code in order to answer my question.

Answer

I do not know what to supply as a node.

It means you can pass any of...

  • document.getElementById('abc')
  • $('#abc')
  • #abc

It means it probably wraps the argument with $(), meaning it will automatically support all three.