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

Forum

Log In Sponsors
Board index Programming CSS Forum

Highlight Link

Highlight Link

Postby Johnathan on Sun Jun 01, 2008 10: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: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland

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

Something like this:

onrollover yadayadayada style="background-color: #FFFF66"
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

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

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

Postby Johnathan on Mon Jun 02, 2008 7: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: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland

Postby rangana on Mon Jun 02, 2008 7: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 ;)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

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

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

Postby rangana on Mon Jun 02, 2008 8: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.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

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

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

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

No worries, glad to help ;)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 0 guests