User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 401,639 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,833 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

javascript css background-image

Join Date: Nov 2007
Posts: 26
Reputation: chrelad is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
chrelad's Avatar
chrelad chrelad is offline Offline
Light Poster

Help Re: javascript css background-image

  #2  
Jan 1st, 2008
Hi rnr8,

Instead of using the DOM to change the backgroundImage property, try changing the className property of the element and creating a stylesheet rule for the class name.

javascript:

el.className = 'hover';

Stylesheet:

li.hover{
  background-color:#f90;
  font-weight:bold;
  text-decoration:underline;
}

Remember though, it's better to change the styles of anchors instead of li's when dealing with mouseover's due to incomplete support for mouseover event handling and the like in different browsers. Anchor's (<a>) already have :hover, :active, :visited, etc stylesheet capabilities in the revision 1 of the w3c's specification (http://www.w3.org/TR/CSS1#anchor-pseudo-classes). Try changing the background image on the anchors instead of the li's if you want to keep your menu/list viewable by the widest possible audience. Just a tip

Great question rnr8
Last edited by chrelad : Jan 1st, 2008 at 11:04 pm. Reason: Forgot to wrap the CSS in code tags
Reply With Quote  
All times are GMT -4. The time now is 6:16 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC