homepage Welcome to WebmasterWorld Guest from 54.161.192.130
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Mouse Over Detection
How do detect if a mouse is over a UL?
Sekka

5+ Year Member



 
Msg#: 3289522 posted 12:52 pm on Mar 22, 2007 (gmt 0)

Hi,

This may exist somewhere but I not sure what I am searching for being new to JS so I apologise if it is a widely known thing.

I need to know whether a mouse is over an unordered list (<ul>) or not. I am making a simple drop down menu from scratch and I don't really want to use 3rd party code due to licensing, etc.

When you roll over a button, the UL list below it is revealed, and I need to know if thr mouse then goes over it or not.

Thank you.

 

Moby_Dim

10+ Year Member



 
Msg#: 3289522 posted 1:13 pm on Mar 22, 2007 (gmt 0)

The simplest:
<ul onmouseover="alert('Mouse is over!')">
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
<li>e</li>
</ul>

to be more precise, you may define width and height too may be.

Sekka

5+ Year Member



 
Msg#: 3289522 posted 1:23 pm on Mar 22, 2007 (gmt 0)

Thank you.

Can you add an onmouseover event to a UL or link by function?

For exmaple, I have <body onload="init()">

Can this init() function place the onmouseover events onto a normal A tag link and a UL?

BlobFisk

WebmasterWorld Senior Member blobfisk us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3289522 posted 1:30 pm on Mar 22, 2007 (gmt 0)

You can add an event listener to any element on a page. Do a search for addEventListener.

HTH

Sekka

5+ Year Member



 
Msg#: 3289522 posted 2:16 pm on Mar 22, 2007 (gmt 0)

Works a treat. Thank you for the help!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved