Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
183
rated 0 times [  187] [ 4]  / answers: 1 / hits: 102950  / 15 Years ago, tue, november 17, 2009, 12:00:00

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


More From » dom

 Answers
47

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>';

[#98293] Friday, November 13, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mariamiyanab

Total Points: 75
Total Questions: 102
Total Answers: 92

Location: British Indian Ocean Territory
Member since Tue, Feb 22, 2022
2 Years ago
;