We help IT Professionals succeed at work.

insert HTML into selected element

Tom Knowlton
Tom Knowlton used Ask the Experts™
on
Before:

<div id="foo"><div id="one"></div><div id="two"></div></div>

After:

<div id="foo"><div style="width:20px;height:20px;background-color:red;"<div id="one"></div><div id="two"></div></div>

-placed before original content of div "foo"
-does not overwrite original content of div "foo"


Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
$('#foo').prepend('"><div style="width:20px;height:20px;background-color:red;">');
Oops, sorry...

$('#foo').prepend('<div style="width:20px;height:20px;background-color:red;">');
Tom KnowltonWeb developer

Author

Commented:
quality!
Thanks!