How can I convert a DOM node to a jQuery object? I am using a javascript library that is returning a DOM node. I don't know any of its properties. I want to convert it to a jQuery object so that I can work with it.

hi Queen,

Convert DOM object to jQuery object is made by attaching it in a selector

  • .jquery,.context,.length,.selector these are some properties of jQuery object.
  • jQuery Objects that are return or created by jQuery()

  • Every DOM object is a Node.(except one or two or more).

  • The DOM object is the “regular” un-wrapped object you can get without jQuery
  • Dom Elements that are retrieved. Example document.getElementById();
  • .name, .value are properties of Dom object.

So we can covert each other

//From jQuery object to Dom:
var domobject = jqueryObject.get();

//From Dom to jQuery object
var jqueryObject = jQuery(domobject);


//From Dom to jQuery object
var overlayContent = document.createElement("div");

The keyword this tells to the DOM element to which the handler is bound, so ‘this’ is not a jQuery object, but it just one step away from making it into jQuery by using $(this).

I'm not being able to understand what would "jQuery Object" mean exactly, since I don't use it. But...

I suppose that when referenced upon - these jq., dom objects - are somehow wrapped by it enabling you to use few or more extra methods not available on DOM api, - than the quickest run about might be by setting its "display" property to 'none' and perhaps give it an ID before appending it to the document so you can create a jQ handle for it with a conventional jQuery call as with any other element.

It's a workaround, but might serve you well until some other more direct route is found.
This is, of course - in case that the code from above didn't work for you.