/    Sign up×
Community /Pin to ProfileBookmark

A very simple one ( I know!)

Hi,
my question is a very simple one. I knew the solution but it is escaping me at this moment. This is the code:
<body>
<p id=”color”>Text to be colored</p>
<p><a href=”#” onclick=”document.getElementById(‘color’).fgColor=’#ff0000′;”>clik me</a></p>
</body>

What I want is that, when we click on the text “clik me” the text color of “Text to be colored” should change. I don’t understand where I may be commiting a mistake. Pls help me out without laughing on the silly problem I have put.
Thanks.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayMay 17.2006 — Try:

onclick="document.getElementById('color').style.color='#ff0000';"
Copy linkTweet thisAlerts:
@DivyakediaauthorMay 18.2006 — This is the new code and is not working.

<style>

a:link{color:#FFFFFF}

a:visited{color:#FFFFFF}

a:hover{color:#FFFFFF}

</style>

<script language="javascript">

function hideSideBar()

{

document.getElementById("change").style.color="#ff0000"

var s=document.getElementById("panel_content");

var m=document.getElementById("main_content");

s.innerHTML= "";

s.style.width="0%";

m.style.width="100%";

}

</script>

<title>Untitled Document</title>

</head><body>

<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">

<tr>

<td width="323" bgcolor="#D4D0C8" id="main_content">This is the Main Panel and if U hide the right panel,<br>

then this panel will fill the space. <div id="change"><font color="#D4D0C8">U can regain the panel by hitting F5. </font></div></td>

<td width="206" align="center" bgcolor="#000000" id="panel_content">

<p><font color="#FFFFFF">

<a href="#" onClick="hideSideBar();">Hide This Bar</a> { At your own risk}</font></p>

<p><font color="#FFFFFF"><marquee direction="up" width="150"><img src="images/ap_125x94.gif" width="125" height="94" />

</marquee></font></p></td>

</tr>

</table>

This code hides the panel, and the main content panel takes up the rest of the space. I want the text that is hidden at this moment to show up thru the code that U gave. Is it possible? ( I think nothing is impossible in JS.)

Thanks.
Copy linkTweet thisAlerts:
@ranjas75May 18.2006 — What content panel are you trying to have take up the rest of the space?
Copy linkTweet thisAlerts:
@DivyakediaauthorMay 18.2006 — I want "main_content" to take up the space and the text "U can regain the panel by hitting F5." that has the id "change" will also show up.
×

Success!

Help @Divyakedia spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...