Forum Moderators: open

Message Too Old, No Replies

replace content of <div> element

         

jelleast

3:26 pm on Nov 15, 2006 (gmt 0)

10+ Year Member



hello,

i'm trying to make this cms in javascript,
but i ran in to a problem:

i can't figure out how to replace the content of a <div> (not iframe :P)

here's what i want, the <div> contains some text and pictures:

<div id="div1">blablabla<img src="hello.png">blabla</div>

i want to replace this content "blablabla<img src="hello.png">blabla" with: "whatever<img src="whatever.png">whatever"

how do i manage this in javascript, thanx a lot!

greetings jelle

Little_G

3:36 pm on Nov 15, 2006 (gmt 0)

10+ Year Member



Hi,


document.getElementById('div1').innerHTML = 'whatever<img src="whatever.png">whatever';

Should do it.

Andrew

bwstyle

9:54 pm on Nov 15, 2006 (gmt 0)

10+ Year Member



You can also include this javascript in your page...

<snip>

... and reference your element ids in a much eaiser fashion (well it's much easier when you have a lot of these.)

$('div1').innerHTML = 'whatever<img src="whatever.png">whatever';

[edited by: encyclo at 1:51 pm (utc) on Nov. 16, 2006]
[edit reason] terms of service [webmasterworld.com] [/edit]

jelleast

10:54 pm on Nov 15, 2006 (gmt 0)

10+ Year Member



thanx a lot :D
it worked!

greetings jelle