/    Sign up×
Community /Pin to ProfileBookmark

change span style on mouseover td

i have

[CODE]<a href=”#”><td width=”100″ height=”32″ align=”center” valign=”center” onmouseover=”this.className=’menuactive’;” onmouseout=”this.className=’menu’;” class=”menu”><span class=”menu” id=”home”>Home</span></td></a>[/CODE]

i would like to replace the “this.” with somthing like “document.getelementbyid(home).” but i’m not very good with javascript and cant get the line exactly correct.

help appreciated

adam

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@PittimannFeb 10.2004 — Hi!i would like to replace the "this." with somthing like "document.getelementbyid(home)."[/QUOTE]Two things:

Please use getElementById (js is case sensitive) and put single quotes around home...

Cheers - Pit
Copy linkTweet thisAlerts:
@neil9999Feb 10.2004 — This should work:

[code=php]
<a href="#">
<table>
<tr>
<td width="100" height="32" align="center" valign="center" onmouseover="document.getElementById('home').className='menuactive';" onmouseout="document.getElementById('home').className='menu';" class="menu"><span class="menu" id="home">Home</span></td></a>
[/code]


You need to put the id in the brackets in ' s.

Neil
×

Success!

Help @Popey 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.17,
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,
)...