JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 29th, 2005, 10:50 PM
jimheng jimheng is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 108 jimheng User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 26 m 50 sec
Reputation Power: 10
Changing the Font color with SPAN

Here I got a new problem about changing the font color when the mouse over some text.

The below codes work perfectly if only got 2 fonts which change each other when the mouse over them.
Code:
<span id="one" onMouseOver="document.getElementById('two').style.color='red'" onMouseOut="document.getElementById('two').style.color='black'">123</span>
<span id="two" onMouseOver="document.getElementById('one').style.color='red'" onMouseOut="document.getElementById('one').style.color='black'">abc</span>


Now, there had the third font called "abc123" and I want this font change color to red when the font "123" is over by mouse. Here is the code I cant image how to slove.
Code:
<span id="one" onMouseOver="document.getElementById('two').style.color='red'" onMouseOut="document.getElementById('two').style.color='black'">123</span>
<span id="two" onMouseOver="document.getElementById('one').style.color='red'" onMouseOut="document.getElementById('one').style.color='black'">abc</span>
<span id="two">abc123</span>


Description:
I need the word "abc" and "abc123" change to red color when the word "123" is over by mouse.

Anyone got a idea to do this?
__________________
Success is coming from your repeat failure
Berjaya Datang Dari Banyak Kali Gagal
失败是成功之母

I am welcome you visit my site.
http://www.jhmss.com

Reply With Quote
  #2  
Old May 29th, 2005, 11:20 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,817 jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 4 Days 7 h 14 m 56 sec
Reputation Power: 1098
You cannot have two identical ids; that defeats the purpose. If you give the abc123 <span> its own id, like "three", then you can getElementById('three') in the same onMouseOver that you do for 'two'.

BTW, there is a keyword called "this" that refers to the current element:
Code:
<span id="one" onmouseover="this.style.color='red';">123</span>
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Reply With Quote
  #3  
Old May 29th, 2005, 11:36 PM
jimheng jimheng is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 108 jimheng User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 26 m 50 sec
Reputation Power: 10
Is there no any way to do this?

Or can I change the text into the INPUT type.
Then use the form tag to change the style?

Can this function well?
Thanks ur comments.

Reply With Quote
  #4  
Old May 30th, 2005, 12:07 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,817 jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 4 Days 7 h 14 m 56 sec
Reputation Power: 1098
Quote:
Originally Posted by jimheng
Is there no any way to do this?
Quote:
Originally Posted by jharnois
If you give the abc123 <span> its own id, like "three", then you can getElementById('three') in the same onMouseOver that you do for 'two'.
Code:
<span id="one" onMouseOver="document.getElementById('two').style.color='red';document.getElementById('three').style.color='red';  " onMouseOut="document.getElementById('two').style.color='black';document.getElementById('three').style.color='bla  ck';">123</span>
<span id="two" onMouseOver="document.getElementById('one').style.color='red'" onMouseOut="document.getElementById('one').style.color='black'">abc</span>
<span id="three">abc123</span>

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Changing the Font color with SPAN

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap