- Element: mouseover event
- Syntax
- Event type
- Event properties
- Examples
- HTML
- JavaScript
- Result
- Specifications
- Javascript on mouse not over jquiery
- Jquery — Menu mouse over on <a> not <a> <span>
- On mouse over specific text show using jquery
- Javascript onChange only when using mouse
- Mouse Over only on text not on entire row
Element: mouseover event
The mouseover event is fired at an Element when a pointing device (such as a mouse or trackpad) is used to move the cursor onto the element or one of its child elements.
Syntax
Use the event name in methods like addEventListener() , or set an event handler property.
addEventListener("mouseover", (event) => >); onmouseover = (event) => >;
Event type
Event properties
This interface also inherits properties of its parents, UIEvent and Event . MouseEvent.altKey Read only Returns true if the alt key was down when the mouse event was fired. MouseEvent.button Read only The button number that was pressed (if applicable) when the mouse event was fired. MouseEvent.buttons Read only The buttons being pressed (if any) when the mouse event was fired. MouseEvent.clientX Read only The X coordinate of the mouse pointer in local (DOM content) coordinates. MouseEvent.clientY Read only The Y coordinate of the mouse pointer in local (DOM content) coordinates. MouseEvent.ctrlKey Read only Returns true if the control key was down when the mouse event was fired. MouseEvent.layerX Non-standard Read only Returns the horizontal coordinate of the event relative to the current layer. MouseEvent.layerY Non-standard Read only Returns the vertical coordinate of the event relative to the current layer. MouseEvent.metaKey Read only Returns true if the meta key was down when the mouse event was fired. MouseEvent.movementX Read only The X coordinate of the mouse pointer relative to the position of the last mousemove event. MouseEvent.movementY Read only The Y coordinate of the mouse pointer relative to the position of the last mousemove event. MouseEvent.offsetX Read only The X coordinate of the mouse pointer relative to the position of the padding edge of the target node. MouseEvent.offsetY Read only The Y coordinate of the mouse pointer relative to the position of the padding edge of the target node. MouseEvent.pageX Read only The X coordinate of the mouse pointer relative to the whole document. MouseEvent.pageY Read only The Y coordinate of the mouse pointer relative to the whole document. MouseEvent.relatedTarget Read only The secondary target for the event, if there is one. MouseEvent.screenX Read only The X coordinate of the mouse pointer in global (screen) coordinates. MouseEvent.screenY Read only The Y coordinate of the mouse pointer in global (screen) coordinates. MouseEvent.shiftKey Read only Returns true if the shift key was down when the mouse event was fired. MouseEvent.mozInputSource Non-standard Read only The type of device that generated the event (one of the MOZ_SOURCE_* constants). This lets you, for example, determine whether a mouse event was generated by an actual mouse or by a touch event (which might affect the degree of accuracy with which you interpret the coordinates associated with the event). MouseEvent.webkitForce Non-standard Read only The amount of pressure applied when clicking. MouseEvent.x Read only Alias for MouseEvent.clientX . MouseEvent.y Read only Alias for MouseEvent.clientY .
Examples
HTML
ul id="test"> li>item 1li> li>item 2li> li>item 3li> ul>
JavaScript
const test = document.getElementById("test"); // This handler will be executed only once when the cursor // moves over the unordered list test.addEventListener( "mouseenter", (event) => // highlight the mouseenter target event.target.style.color = "purple"; // reset the color after a short delay setTimeout(() => event.target.style.color = ""; >, 500); >, false, ); // This handler will be executed every time the cursor // is moved over a different list item test.addEventListener( "mouseover", (event) => // highlight the mouseover target event.target.style.color = "orange"; // reset the color after a short delay setTimeout(() => event.target.style.color = ""; >, 500); >, false, );
Result
Specifications
Javascript on mouse not over jquiery
Solution 1: i think problem lies with how you define var element because shows anchor tag and span both are child of li so $(this) can be defined as ‘a’ and ‘span’ best solution remove span i don’t think they are in use Solution 2: Try making things simpler for yourself, is this what you wanted to do ? There are a lot of ways to handle it, but one easy way is just to wrap them with spans and trigger the on those spans: http://jsfiddle.net/xneG5/ Programatically: http://jsfiddle.net/xneG5/2/ CSS only: http://jsfiddle.net/xneG5/3/ Solution 2: Setting the margins and padding of the li elements to 0 could possibly solve this problem.
Jquery — Menu mouse over on <a> not <a> <span>
I am hacking the following menu on this page: http://cssmenumaker.com/menu/slabbed-accordion-menu
I want to to expand on hover so that I can have a link on the top level menu item as well as the expanded items.
I have the following code in my script that works on hover and on the mobile when tapped.
( function( $ ) < $( document ).ready(function() < $('#cssmenu li.has-sub >a ').on('mouseover', function() < $(this).removeAttr(''); var element = $(this).parent('li'); if (element.hasClass('open')) < element.removeClass('open'); element.find('li').removeClass('open'); element.find('ul').slideUp(); >else < element.addClass('open'); element.children('ul').slideDown(); element.siblings('li').children('ul').slideUp(); element.siblings('li').removeClass('open'); element.siblings('li').find('li').removeClass('open'); element.siblings('li').find('ul').slideUp(); >>);
The issue I have is that when the mouse pointer hovers over the ‘li.has-sub a’ it expands fine, but it also triggers again when the ‘li.has-sub a span’ is hovered over. How can I prevent the within the link also triggering the event?
Any help is much appreciated.
i think problem lies with how you define var element because
var element = $(this).parent('li');
shows anchor tag and span both are child of li so $(this) can be defined as ‘a’ and ‘span’
best solution remove span i don’t think they are in use
Try making things simpler for yourself, is this what you wanted to do ?
Javascript — Tooltip — Won’t hide on mouse out, While it does work, if I hover over too fast the tooltip doesn’t disappear. Is there a way to ensure the tooltip hides on mouse out, or on click (for mobile friendly): // on mouse over, make a call to DB using AJAX and return results into tooltip j$ ( ‘ [data-toggle=tooltip]’ ).on ( ‘mouseover’, function ( e ) < var …
On mouse over specific text show using jquery
I have li elements in that image and text will be there. Bydefault text will be hide. On mousehovor i want to show respective text.
jQuery(".icon-list-fixed-right .fa-whatsapp").on("mouseover", function () < jQuery('this').find('span.elementor-icon-list-text').find('span.elementor-icon-list-text').css('opacity','1'); //console.log(jQuery('this').closest('li.elementor-icon-list-item').find('span.elementor-icon-list-text')); >);
.icon-list-fixed-right .elementor-icon-list-text
On mousehover i am not getting text. If anyone have idea what exact wrong then let me know.
First you need to remove the » that is surrounding your this in jquery(‘this’)
Second your ´text´ is not a child of the icon, so you can’t use .find()
jQuery(".icon-list-fixed-right .fa-whatsapp").on("mouseover", function() < jQuery(this).parent().next(".elementor-icon-list-text").css('opacity', '1'); >);
jQuery(".icon-list-fixed-right .fa-whatsapp").on("mouseover", function() < jQuery(this).parent().next(".elementor-icon-list-text").css('opacity', '1'); >);
Jquery — Javascript onmouseover event working but need, You could use jQuery and use the .hover function. This function performs both mouseenter and mouseleave functions for you so you only need to specify what should happen. Also, you should specify your styling in a CSS file. This solution does not supply you with an inline solution, but does reduce your code …
Javascript onChange only when using mouse
I have a Javascript function that captures the onChange of a select dropdown. Is it possible to fire an event only when the user selects the item using the mouse form the dropdown, not when he scrolls up or down using the keyboard?
Have you tried this : div Trigger the handler