homepage Welcome to WebmasterWorld Guest from 54.204.142.143
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
JavaScript needed
JakeFrederick




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

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?

 

MikeFoster




msg:1491522
 5:32 am on Sep 16, 2001 (gmt 0)

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>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved