search

Home  >  Q&A  >  body text

javascript - Can jquery .on('click',function(event){}) be changed to trigger when the mouse passes by?

Can jquery .on('click', function(event){}) be changed to trigger when the mouse passes by?

曾经蜡笔没有小新曾经蜡笔没有小新2707 days ago845

reply all(4)I'll reply

  • 欧阳克

    欧阳克2017-06-26 11:00:35

    mouseover

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-06-26 11:00:35

    You can also use mouseenter and mouseleave encapsulated by JQ to achieve different effects

    reply
    0
  • 漂亮男人

    漂亮男人2017-06-26 11:00:35

    I wrote it wrong, it should be a selector in front of it. It should be $("xxx").on("mouseenter",function(){}). This is triggered when the mouse enters. If you want to change it to trigger after leaving, change it to 'mouseleave'. Or use 'hover'. It is not recommended to use the three events of mouseover, mouseout, and mousemove. Mouseover and mouseout will also trigger events when entering or leaving child elements. The mousemove event is triggered too frequently and too high.

    reply
    0
  • PHP中文网

    PHP中文网2017-06-26 11:00:35

    If you just want to bind the mouse floating event, look at the code above. If you just want to trigger the click, look at the code:

    $('p').on("mouseover",function(e){
        $(this).trigger("click");
    });

    reply
    0
  • Cancelreply