Take all ajaxed li's

Viewed 41

Problem is that I cant find a way to take all li.form-field elements from ajax'ed content. Tried function find in many ways. I don't understand what is wrong.

For example I do this console.log("fields", $(self.element)[0]);

And I can see that the elements .form-field exists

enter image description here

but when I try to take them, it returns error.

console.log("fields", $(self.element)[0].find('.form-field'));
1 Answers

Assuming you are using something like jQuery load you should access the element(s) after jQuery has finished it's request and set the dom:

$( "#result" ).load( "ajax/test.html", function() {
  console.log("form fields:",this.querySelectorAll('.form-field').length);
});
Related