[Solved] Check if dynamically created element has class


Are you adding the element to the DOM after the page is ready?
If you so, you can just check if the element has the class as you described in your question.

However, if the element is being added before the DOM is ready, simply do this:

$(document).ready(function () {
   if($('.list li').hasClass('aDynamicallyGeneratedClass')){
     //Then do this with my object.
   });
});

When the DOM is ready, then this function will fire.
I hope this helps!
Cheers!

0

solved Check if dynamically created element has class