p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   How to get the value of pre? (http://p2p.wrox.com/showthread.php?t=30914)

Edward King June 28th, 2005 02:26 AM

How to get the value of pre?
 
I have a pre tag in the HTML,like follows:
<form name='myform'>
<pre id='a' style="margin:0px;">
12345 912345 12345
</pre>

<script language="JavaScript" type="text/JavaScript">
alert(document.myform.a.value);
</script>
</form>

I want to get the value of pre tag,is there any method to do it? I use alert sentence to show it,but IE raise an error:
document.myform.a.value is null or not object.

Thanks for any help


ChrisScott June 28th, 2005 03:27 AM

Hi Edward,

Try this...
Code:

alert(document.getElementById("a").innerHTML);
HTH,

Chris


deniscuba June 28th, 2005 07:38 AM

this is the way:

alert(document.getElementById("a").innerText);

Regards.
        Denis




All times are GMT -4. The time now is 07:52 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.