如何更改点击鼠标悬停或悬停在jquery? [英] how to change click to mouseover or hover through jquery?

查看:72
本文介绍了如何更改点击鼠标悬停或悬停在jquery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在鼠标悬停或悬停时显示日期,现在它是onclick,我已经使用工具提示显示数据但我想在鼠标悬停时显示数据,我尝试了很多但没有成功?任何机构都可以提供帮助,谢谢,提前谢谢。

i want to display the date on mouseover or hover, right now it's onclick, i have used tooltip to display the data but i want to show the data on mouseover, i tried a lot but didn't get success? any body can help it will be appreciated, thanks in advance.

这是我的代码,它希望在clik上更改为mouseiver / hover。

this is my code, it want to change on clik to mouseiver/hover.

 <script>
 $(".ajax_link").click(function(e) {

e.preventDefault(); //Stops link from changing the page

var link = $(this).attr('href'); //Gets link url

$.ajax({ //Make the ajax request
  url: link,
  cache: false
}).done(function( html ) { //On complete run tooltip code

    //Display tooltip code goes here, returned text is variable html
    .done(function( html ) { 
        alert("text: " + html);
    });
});
});
</script>


推荐答案

您可以尝试更改此内容:

You can try changing this:

$(".ajax_link").click(function(e) {

到此:

$(document).on('hover mouseover mouseenter', ".ajax_link", function(e) {
     //e.preventDefault(); //<-------you can take this out no need for this

如果您想停止跳转页面,那么您可以这样做:

if you want to stop the jump of page then you can do this:

$(".ajax_link").click(function(e) {
   e.preventDefault(); // or return false;
});

这篇关于如何更改点击鼠标悬停或悬停在jquery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆