Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

JavaScript knocks out CSS:hover

Featured Replies

Hi im trying to make the Product Categories menu work on this page:

 

http://www.jaybrand.co.uk/p1.html

 

at the moment the page loads and CSS hover works to set the background position so that the graphic behind makes a roll over effect.

 

i put some javascript to set the background position to the roll over on click, but this knocks out the CSS hover:

 

onclick="setStyle('c1','backgroundPosition','0px 0px');

 

 

it means that c1:hover no longer works.. i tried putting !important in the CSS c1:hover background position and this fixed it in Firefox but not IE.

 

How can i write something in Javascript to also say:

 

onclick="setStyle('c1:hover','backgroundPosition','-276px 0px');

 

 

 

......... i know Javascript does not do hyphens and the way to get for example "background-position" in CSS is to ditch the hyphen and make "P"osition capitol. perhaps something can be done also to get to the CSS hover attribute?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.