I'm having a twitter feed automatically added by a script. I want to add a <br/>
with jquery in it. Now it's like this
<ul id="twitter_update_list">
<li><span>something</span> <a href="#">about 4 hours ago</a></li>
<li><span>something</span> <a href="#">about 6 hours ago</a></li>
</ul>
I want to add a <br/>
after each </span>
with jquery. so that its like this
<ul id="twitter_update_list">
<li><span>something</span><br/> <a href="#">about 4 hours ago</a></li>
<li><span>something</span><br/> <a href="#">about 6 hours ago</a></li>
</ul>
jQuery insertAfter() Method The insertAfter() method inserts HTML elements after the selected elements. Tip: To insert HTML elements before the selected elements, use the insertBefore() method.
jQuery insertBefore() Method The insertBefore() method inserts HTML elements before the selected elements. Tip: To insert HTML elements after the selected elements, use the insertAfter() method.
The insertAfter() is an inbuilt method in jQuery which is used to insert some HTML content after a specified element. The HTML content will be inserted after each occurrence of the specified element. Here the “content” is the HTML content which is to be inserted after the specified target.
jQuery appendTo() Method The appendTo() method inserts HTML elements at the end of the selected elements. Tip: To insert HTML elements at the beginning of the selected elements, use the prependTo() method.
You can use .after()
to insert an element after each the selector matched, like this:
$("#twitter_update_list span").after("<br />");
You can test it out here. The result is...well, exactly what you have in the question :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With