Welcome to WebmasterWorld Guest from 50.16.24.12

Forum Moderators: open

JavaScript needed

   
6:22 pm on Sep 15, 2001 (gmt 0)

10+ Year Member



Can anyone point me to a Javascript example that allows me to change the contents of a <p> element with the press of a button?
5:32 am on Sep 16, 2001 (gmt 0)

10+ Year Member



Hi JakeFrederick,

This is the most direct method, and works with IE5+ and NS6, but not with NN4.x nor Opera.

<html>
<head>
<script type='text/javascript'>
function changeP() {
document.getElementById('p1').innerHTML = "This is the <b>new</b> content for <i>my paragraph</i>.";
}
</script>
</head>
<body>

<form onsubmit='return false'>
<input type='button' value='Click Me' onclick='changeP()'>
</form>

<p id='p1'>This is my paragraph</p>

</body>
</html>

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month