/    Sign up×
Community /Pin to ProfileBookmark

event delegation

Hi,

I have to use JS to drive a flyout menu for IE6. Unfortunately the
given script just handles 1 ID (<ul id=nav>). As I need this flyout
menu several times (link in table) I need to assign the function to
all ids with the name “nav_x” whereby x a counting number represents:
nav_1, nav_2, nav_3…

Here is the current code. Maybe you guys can help me to put this into
a function which takes all nav_x?

[code=html]
sfHover = function() {
var sfEls = document.getElementById(“nav”).getElementsByTagName(“LI”);
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=” sfhover”;
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(” sfhover\b”), “”);
}
}
}
[/code]

thanks

Elli

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Elli 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...