Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

insert/remove HTML content between div tags

Tags:

how can I insert some HTML code between <div id="mydiv">...</div> using javascript?

Ex: <div id="mydiv"><span class="prego">Something</span></div> its about 10 lines of html of most. thank you

like image 756
ant Avatar asked Nov 17 '09 17:11

ant


1 Answers

If you're replacing the contents of the div and have the HTML as a string you can use the following:

document.getElementById('mydiv').innerHTML = '<span class="prego">Something</span>'; 
like image 154
Bryan Kyle Avatar answered Oct 02 '22 17:10

Bryan Kyle