It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Partner Sites
Board index Programming CSS Forum

Highlight Link

Highlight Link

Postby Johnathan on Sun Jun 01, 2008 11:54 pm

Don't really know what to google for. But I want to know how to do that think when you hover over a link the whole thing highlights... Like this http://boagworld.com/ .
Johnathan
1000+ Club
 
Posts: 1204
Joined: Thu May 31, 2007 4:28 pm
Location: Belfast, Northen Ireland

Postby dflynn on Mon Jun 02, 2008 2:15 am

Something like this:

onrollover yadayadayada style="background-color: #FFFF66"
Image
nnjoi.com - Portfolio
nnjoiart.com - Art & Design Blog
bathroomwriter.com - Interested in helping out with Beta Testing? PM me.
User avatar
dflynn
500+ Club
 
Posts: 831
Joined: Wed Oct 03, 2007 10:06 pm
Location: Guelph, Canada

Postby rangana on Mon Jun 02, 2008 2:59 am

Have you tried something along the lines of:
Code: Select all
<a href="#" onmouseover="this.style.background='#0f0';">Link</a>
~ Get me some work, I do freelancing ~
User avatar
rangana
500+ Club
 
Posts: 929
Joined: Wed Feb 27, 2008 6:14 am
Location: Cebu City Philippines

Postby Johnathan on Mon Jun 02, 2008 8:31 am

dflynn wrote:Something like this:

onrollover yadayadayada style="background-color: #FFFF66"


Thank You dflynn.


Code: Select all
<a href="#" onmouseover="this.style.background='#0f0';">Link</a>


Would I not need to insert that for every link?
Johnathan
1000+ Club
 
Posts: 1204
Joined: Thu May 31, 2007 4:28 pm
Location: Belfast, Northen Ireland

Postby rangana on Mon Jun 02, 2008 8:50 am

Yes, it should be, but this can also be done with a for loop, to access every link.

This should work:
Code: Select all
<script type="text/javascript">
window.onload=function()
{
   var rangAs=document.getElementsByTagName('a');
   for(var rangLoop=0;rangLoop<rangAs.length;rangLoop++)
   {
   rangAs[rangLoop].onmouseover=function()
      {
      this.style.background='#0f0'; //background when hovered
      }
   rangAs[rangLoop].onmouseout=function()
      {
      this.style.background='#fff'; //Background when not on hover
      }
   }
}
</script>
<a href="#">Link</a>
<a href="#">Link</a>
<a href="#">Link</a>
<a href="#">Link</a>
<a href="#">Link</a>
<a href="#">Link</a>


See if it helps ;)
~ Get me some work, I do freelancing ~
User avatar
rangana
500+ Club
 
Posts: 929
Joined: Wed Feb 27, 2008 6:14 am
Location: Cebu City Philippines

Postby Johnathan on Mon Jun 02, 2008 8:53 am

But will that not make the links always highlighted and only a different colour on rollover?
Johnathan
1000+ Club
 
Posts: 1204
Joined: Thu May 31, 2007 4:28 pm
Location: Belfast, Northen Ireland

Postby rangana on Mon Jun 02, 2008 9:02 am

What do you mean?

The codes i've given highlights the background when you hovered over it, and returns to its original background.

See coments from the code,..or i'm missing something.
~ Get me some work, I do freelancing ~
User avatar
rangana
500+ Club
 
Posts: 929
Joined: Wed Feb 27, 2008 6:14 am
Location: Cebu City Philippines

Postby Johnathan on Mon Jun 02, 2008 2:11 pm

It's ok I think I understand it now :P, I was in a rush this morning.
Johnathan
1000+ Club
 
Posts: 1204
Joined: Thu May 31, 2007 4:28 pm
Location: Belfast, Northen Ireland

Postby rangana on Tue Jun 03, 2008 1:13 am

No worries, glad to help ;)
~ Get me some work, I do freelancing ~
User avatar
rangana
500+ Club
 
Posts: 929
Joined: Wed Feb 27, 2008 6:14 am
Location: Cebu City Philippines


Return to CSS Forum

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests