悬停无法在禁用的输入字段上工作? [英] Hover not working on disabled input field?

查看:75
本文介绍了悬停无法在禁用的输入字段上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个禁用的悬停输入字段,我想要做一个弹出窗口,说这个字段会自动填充。

   

这是我的 jQuery ,它不起作用。

  $('input:disabled')。hover(
function(){
alert(hello);
},
function(){
alert(bye);
}
);

任何人都可以建议我怎么做到这一点。

解决方案

鼠标事件不会在禁用的字段上被触发。你可以做的是将一个元素放在禁用的字段前面,并将鼠标事件放在该元素上。

这会告诉你如何做到这一点



然而,其他的事情你可以做的是保持该字段启用,并悬停在上,禁用它并显示警报消息。像:

  $('input')。hover(function(){
alert(hello);
$(this).attr('disabled','disabled');
});

我创建了小提琴。您可以在这里查看


I have a disabled input field on hover of which i want to do a popup which says this field will be automatically populated.

<input type="text" class="dcol" data-toggle="popover" data-content="Required Field with Numeric Input" disabled="disabled" style="background-color:#FFFF66" value="">

Here is my jQuery which is not working.

$('input:disabled').hover( 
    function(){
        alert("hello");
    },
    function(){ 
        alert("bye");
    }
 );

Can anyone suggest how I can achieve this.

解决方案

The mouse event will not get fired on the disabled field. What you can do is put an element in front of the disabled field and put your mouse event on that element.

This will tell you exactly how to do it

However, other thing you can do is keep the field enabled and on hover over, disable it and show the alert message. Like:

$('input').hover(function(){
  alert("hello");
   $(this).attr('disabled','disabled');        
});

I have created a fiddle for it. You can check it out here.

这篇关于悬停无法在禁用的输入字段上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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