/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Problem altering CSS

Hello there, I’m trying to change CSS with a mouseover event, it works fine in FF but doesn’t work at all in IE (6, I used to have 7 but FF3 crushed it).
here come’s the code:

[CODE]
<script language=”JavaScript” type=”text/javascript”>
function OverButton(item) {
document.getElementById(item).setAttribute(“class”, “main2”);
}
function OutButton(item) {
document.getElementById(item).setAttribute(“class”, “main”);
}
</script>
[/CODE]

I call it like this:

[CODE]
<a href=”#” onmouseover=”OverButton(‘data1’)” onmouseout=”OutButton(‘data1’)”>link</a>
[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangJul 10.2008 — setAttribute "class" does not work use:document.getElementById(item).className="main2";

http://tobielangel.com/2007/1/11/attribute-nightmare-in-ie
Copy linkTweet thisAlerts:
@PerfidusauthorJul 10.2008 — Thanks Fang, it works fine !!!
×

Success!

Help @Perfidus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...