Jump to content


Rewriting the contents of a div tag


2 replies to this topic

#1 arcath

    Young Padawan

  • Members
  • Pip
  • 78 posts

Posted 16 March 2008 - 11:32 AM

I have some code that looks like this:

<div id="X">Y</div>

i want to be able change Y using a javascript function like:

replace(Y,X)

i then want to run it onclick=""

#2 dotbart

    Young Padawan

  • Members
  • Pip
  • 141 posts
  • Gender:Male
  • Location:Diepenbeek
  • Interests:Webdesign, Webdeveloppement, DJ, ...

Posted 16 March 2008 - 12:17 PM

<script>
function replace(divID,setText){
document.getElementById(divID).innerHTML = setText;
}
</script>
<div id='test1'>This is a dummy text</div>
<a href="java script:;" onClick="replace('test1','dummytext 2');">Replace it!</a>

something like this? Or by replace do you mean looking for some text in some div and replacing it?




B

#3 arcath

    Young Padawan

  • Members
  • Pip
  • 78 posts

Posted 16 March 2008 - 01:19 PM

Thanks that exactly what i need





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users