handling if an element doesnt exist?
- var d = $(document.createElement('div'));
-
- d.html($("#blog_reply_template_holder").html());
- $('.blog_comment_reply_holder:first').before(d);
Above is a cut down version of my code.
I am dynamically adding blog comments to the dom.
This works fine when I have comments on the page already, but when this is the first comment I have a problem as there is no :
.blog_comment_reply_holder:first
What would be a better way to handle this to ensure that my new div still gets added to the page?