Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Select text in DIV tag


Message #1 by "Seb Burnett" <s.burnett@u...> on Fri, 12 Oct 2001 12:09:58
If you give the DIV an ID (<DIV id=MyDIV>), then you can access it via
MyDIV.innerText.

CODE FOLLOWS:

<HEAD>
<SCRIPT language="Javascript">
function ShowDIV()
{
   alert(MyDIV.innerText);

}

</SCRIPT>
</HEAD>
<BODY>
<DIV ID=MyDIV>
This is an example of DIV text
</DIV>
<input type="button" value="Click me to see DIV text" onclick="ShowDIV()">
</BODY>

END OF CODE

That will let you read the text in a DIV tag.

Good luck,
Klynt Klimek
Klynt@w...

-----Original Message-----
From: Seb Burnett [mailto:s.burnett@u...]
Sent: Friday, October 12, 2001 12:10 PM
To: JavaScript HowTo
Subject: [javascript_howto] Select text in DIV tag


Hi,
I was wondering how I could select all the text in a div tag.

Thank you

Seb

  Return to Index