Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include an element's margin in the hot-spot for jQuery's hover() event?

   jQuery(".my_container").hover(function(){
    //do code
   }, function(){
    //do code
   });

.my_container { width: 100px; height: 100px; margin: 50px; }

The code above doesn't react to mouse over of margin (margin isn't a part of element?) - how can I change that?

like image 745
Atadj Avatar asked Jul 02 '12 17:07

Atadj


People also ask

How do you hover an element?

The :hover selector is used to select elements when you mouse over them. Tip: The :hover selector can be used on all elements, not only on links. Tip: Use the :link selector to style links to unvisited pages, the :visited selector to style links to visited pages, and the :active selector to style the active link.

What is the event for hover in Javascript?

The hover() method specifies two functions to run when the mouse pointer hovers over the selected elements. This method triggers both the mouseenter and mouseleave events. Note: If only one function is specified, it will be run for both the mouseenter and mouseleave events.

How do I hover in PHP?

php runs on the server and has no gui, period. there is no "hover" in php. you can use clientside javascript to do an ajax request on hover, but then that's not php... Users can't hover over an element before the page has even been sent to the browser.

What is the mouseover event?

The onmouseover event occurs when the mouse pointer is moved onto an element, or onto one of its children. Tip: This event is often used together with the onmouseout event, which occurs when a user moves the mouse pointer out of an element.


1 Answers

You could use a 50px transparent border instead - the margin isn't really supposed to be mouseable...

like image 95
Dave Everitt Avatar answered Sep 30 '22 19:09

Dave Everitt