html - How can I append a div in jquery right after some text? -


i have jquery script:

$(document).ready(function() {     $("#timezone").html("sssssss");     }); 

and html:

<p>lorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsum <div id="timezone"></div></p> 

so far result of is:

lorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsum   sssssss 

but want have it:

lorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsum sssssss 

how can it? here's fiddle: http://jsfiddle.net/mwfplqm7/1/

use span instead of div. can't use divs inside p element.

<p>lorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsum <span id="timezone"></span></p> 

fiddle

your browser outputs html div outside of p element because invalid html markup , anyway div block element.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -