I have three td’s and am trying to limit the function inside each to only that td. How do I do this? With this code, it’s taking all 3 images and inserting all of them before the h2:
jQuery("td.frontpage_news").each(function() {
jQuery("span.frontpage_news p:first-child").has("a img").insertBefore("h2.contentheading.frontpage_news"); });
You can use
$(this)to get the element currently being processed by theeach– using that object in conjunction with find will allow you to scope your calls:This assumes that the content heading and front page news items are children of the td.