Is there a non-hackish way to append to or use some elem (noted by an id) and append to it but after it before a block element. Not sure how to explain this.
I have various pages. And I have to insert some data (that is generated via ajax). Now, this data is retrieved after the page is loaded and as such, I have to inject some content – but because the pages are different (I want to use a plugin so I can just drop it into these pages and boom – dynamic content is placed appropriately).
** EDIT ::: If there is text after the HREF, my inserted items must be after it (and subsequent br tag). I was thinking that perhaps I insert after the href up to the last block element (div) or if not, then bottom of the div (noted in last example).
for some pages, the layout is like this..
<td>
<div>
<a href="someurl" id="uniqueIDhere">monsters</a> come see this show!!<br>
// span with content injected here
</div>
or
<td>
<div>
<a href="someurl" id="uniqueIDhere">monsters</a>
// span with content injected here
</div>
or
<td>
<a href="someurl" id="uniqueIDhere">monsters</a>
// span with content injected here
</td>
or
<td>
<div>
<span>
<a href="someurl" id="uniqueIDhere">monsters</a> yo you yo yo yo<br>
</span>
// span with content injected here
</div>
So, that href could be wrapped in a DIV or a SPAN or not.. but its always in a TD..
So, basically I want to inject my “new dynamic” data within the last div of the TD or if there is none, just at the end of the td (but still in it).
any ideas? I figure to use the href ID (should use this as there are a few links i Have to do this to), get the parent TD and then append to it in some fashion?
Seems like you’re looking for the jQuery
after()method:EDIT:
After reading this question again, I think you may be looking for
.append():Here we use
.has()to filter the list ofdivelements that do not containuniqueIDhereand then use.append()to add the text, html, etc.. to the end of thediv.EXAMPLE