Skip to content
Advertisement

jquery: unable to find elements from jQuery object

I am fetching HTML string and I want to construct a jQuery object from it and then perform operations but I am getting undefined.

JavaScript

Advertisement

Answer

find() is used to look for child elements. #rendered is the parent node in the HTML structure you create, so find() doesn’t return anything. You need to use filter() instead as that includes the current node when searching.

Also note that $.parseHTML() isn’t required – jQuery does this automatically when you provide a HTML-formatted string to the jQuery object contructor.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement