How can I convert a DOM element to a jQuery element

0 votes

I am creating an element with document.createElement(). Now how can I pass it to a function that only takes a Jquery object?

$("#id") 

I can not use it, as the element has not been rendered in the page yet.

Nov 25, 2020 in JQuery by kartik
• 37,520 points
2,493 views

1 answer to this question.

0 votes

Hello,

Use this:

var elm = document.createElement("div");
var jelm = $(elm);//convert to jQuery Element
var htmlElm = jelm[0];//convert to HTML Element
answered Nov 25, 2020 by Niroj
• 82,840 points

Related Questions In JQuery

0 votes
1 answer

How to scroll to element from bottom to top with a nice animation using Jquery?

Hello @kartik, Assuming you have a button with ...READ MORE

answered Sep 10, 2020 in JQuery by Niroj
• 82,840 points
4,251 views
0 votes
1 answer

How can I determine the direction of a jQuery scroll event?

Hello @kartik, Check current scrollTop vs previous scrollTop var lastScrollTop = 0; $(window).scroll(function(event){ ...READ MORE

answered Nov 24, 2020 in JQuery by Niroj
• 82,840 points
870 views
0 votes
1 answer

How can I refresh a page with jQuery?

Use the JavaScript location. reload() Method You can simply ...READ MORE

answered Jun 10, 2022 in JQuery by gaurav
• 23,260 points
977 views
0 votes
1 answer

How do I select a sibling element using jQuery?

Use jQuery . siblings() to select the matching ...READ MORE

answered Jun 6, 2022 in JQuery by Edureka
• 13,690 points
479 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
23,295 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,840 points
3,313 views
0 votes
1 answer

How to enable Bootstrap tooltip on disabled button?

Hii @kartik, You can wrap the disabled button ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,840 points
5,102 views
+1 vote
2 answers

How to set cache false for getJSON in jQuery?

You can't pass any configuration parameters to ...READ MORE

answered Oct 7, 2020 in JQuery by Amit
• 140 points
2,931 views
0 votes
1 answer

How can I refresh a page with jQuery?

Hello @kartik, Use location.reload(): $('#something').click(function() { location.reload(); }); The reload() function ...READ MORE

answered Sep 10, 2020 in JQuery by Niroj
• 82,840 points
2,167 views
0 votes
1 answer

How can I select an element with multiple classes in jQuery?

Hello @kartik, If you want to match only ...READ MORE

answered Sep 10, 2020 in JQuery by Niroj
• 82,840 points
3,445 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP