Jquery Trigger Hover On Anchor

$("#a#trigger").trigger("mouseenter"); $("#a#trigger").trigger("hover"); $("#a#trigger").trigger("mouseover");All 3 of those aren"t working to activate a hover function that I have.

Bạn đang xem: Jquery trigger hover on anchor

$(function() $("a#trigger").hover(function(e) $("div#pop-up").show(); , function() $("div#pop-up").hide(); ); ); });a#trigger is the name of the anchor, & #pop-up is a div element in my web.

The problem is that I want lớn mouse over some event in FullCalendar plugin & those functions aren"t working.Thanks.


*

*

You are on the right track, the problem is the extra # in the selector, just remove the first hash:

$("a#trigger").trigger("mouseenter");Note that since IDs must be unique, there is no need to specify the element type, $("#trigger") is more efficient.

Also chú ý that:

Deprecated in jQuery 1.8, removed in 1.9: The name "hover" used as a shorthand for the string "mouseenter mouseleave". It attaches a single event handler for those two events, and the handler must examine event.type khổng lồ determine whether the event is mouseenter or mouseleave. Bởi vì not confuse the "hover" pseudo-event-name with the .hover() method, which accepts one or two functions.


*

Your jQuery selector should be written as e.g.

Xem thêm: Bl Là Gì ? Bill Of Lading

$("a#trigger");instead of $("#a#trigger");

In jQuery a # in a selector matches an id. In this case trigger is an id, but a is an HTML element and requires no prefix.

Your final code would be:

$("a#trigger").trigger("mouseenter");$("a#trigger").trigger("hover");$("a#trigger").trigger("mouseover");

*

Thanks for contributing an answer khổng lồ Stack Overflow!

Please be sure to lớn answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding to lớn other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree lớn our terms of service, privacy policy and cookie policy


Not the answer you're looking for? Browse other questions tagged jquery triggers hover mouseover or ask your own question.


*

site thiết kế / biểu tượng logo © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. Rev2022.3.4.41612


Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.