IPB

Welcome Guest ( Log In | Register )



Tags
This content has not been tagged yet
 
Reply to this topicStart new topic

How Do You Make Text In A <div> Change When You Click On A Link?

, something to do with jvascript


electriic ink
no avatar
Incest is a game the whole family can play.
***********
Group: [MODERATOR]
Posts: 1,239
Joined: 11-February 05
From: Heaven
Member No.: 3,709
myCENT:59.86



Post #1 post Jul 24 2006, 03:11 PM
Say I have a link and some text. How would I make it so that when I clicked on the link, that text changed?
Go to the top of the page
+Quote Post
electron
no avatar
Premium Member
********
Group: Members
Posts: 162
Joined: 10-May 06
Member No.: 23,375
myCENT:35.86



Post #2 post Jul 25 2006, 03:22 AM
Thats pretty easy.
Use the getElementById() function of Java Script.
Then Change the text by using innerHTML function.

If you want to call it by anchor call a function which does the above thing.
Go to the top of the page
+Quote Post
electriic ink
no avatar
Incest is a game the whole family can play.
***********
Group: [MODERATOR]
Posts: 1,239
Joined: 11-February 05
From: Heaven
Member No.: 3,709
myCENT:59.86



Post #3 post Jul 25 2006, 02:57 PM
Thanks electron but after some researching it appears that innerHTML is an IE thing. Is there any function which cross-browser compatible? Thanks....
Go to the top of the page
+Quote Post
truefusion
no avatar
Do you want to know?
****************
Group: [MODERATOR]
Posts: 2,671
Joined: 22-June 05
From: 127.0.0.1 — no place like it.
Member No.: 8,528
myCENT:22.30



Post #4 post Jul 25 2006, 07:12 PM
innerHTML works for me, and i'm using Opera.
CODE
<input type="button" value="Click" onclick="document.getElementById('a').innerHTML='newtext'"/>
<span id="a">text</span>
Go to the top of the page
+Quote Post
electriic ink
no avatar
Incest is a game the whole family can play.
***********
Group: [MODERATOR]
Posts: 1,239
Joined: 11-February 05
From: Heaven
Member No.: 3,709
myCENT:59.86



Post #5 post Jul 25 2006, 07:28 PM
It works for firefox as well. ohmy.gif Oh well, guess you can't believe half of what you read on the internet. Maybe it had Microsoft origins or something.

Thank you electron and truefusion....
Go to the top of the page
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   4 noxit 8,953 19th June 2004 - 05:45 PM
Last post by: OpaQue
No New Posts   6 Echo_of_thunder 1,289 26th March 2009 - 09:04 PM
Last post by: TheDisturbedOne
No new   17 harad 23,044 3rd August 2004 - 11:40 PM
Last post by: MSTR
No new 47 OpaQue 19,650 26th September 2009 - 06:27 PM
Last post by: krishnanz
No New Posts   3 frazmi 2,216 6th August 2006 - 02:20 AM
Last post by: FallenSage
No new   16 -gladiator_us- 21,814 24th August 2009 - 11:05 AM
Last post by: jamjamnorman
No New Posts   7 SilverBoarder 14,235 9th February 2009 - 11:02 AM
Last post by: aloKNsh
No New Posts   3 Plenoptic 1,381 17th July 2006 - 12:06 PM
Last post by: Plenoptic
No new   42 djleli 14,597 4th February 2005 - 10:57 AM
Last post by: alexwhin
No New Posts 6 LuciferStar 14,624 19th September 2009 - 08:57 AM
Last post by: akira550
No New Posts   9 shadowx 3,229 12th October 2009 - 07:12 PM
Last post by: manish-mohania
No New Posts   10 ill 17,520 19th August 2004 - 01:29 PM
Last post by: odomike
No new   20 campainer 14,975 5th December 2004 - 10:30 PM
Last post by: icedragn
No New Posts   6 Dagoth Nereviar 3,426 11th March 2007 - 11:38 PM
Last post by: jlhaslip
No new   14 Raptrex 17,480 8th December 2008 - 01:40 PM
Last post by: carToon


 



RSS Open Discussion Time is now: 8th November 2009 - 07:56 AM

Web Hosting Powered by ComputingHost.com.