As question stated, would like to know is that possible to construct jQuery object from variables. Example as such:
var data = "<div id='bird'>halo world</div>";
console.log($("#bird",$(data)));
JSfiddle link provided.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
$(data)will be constructed by"<div id='bird'>halo world</div>", but you use wrong selector for selecting"#bird"element.$("#bird",$(data))searches within descendants of$(data)element.But as your"#bird"element is not a descendant of that object, you get an empty object. If you need to select"#bird"element, you can use .closest() in this way:Example: