Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

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.

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

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

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



Featured Threads

Hot Threads This Week

Hot Threads This Month