我在悬停时有一个禁用的输入字段,我想做一个弹出窗口,说明这个字段会自动填充。
<input type="text" class="dcol" data-toggle="popover" data-content="Required Field with Numeric Input" disabled="disabled" style="background-color:#FFFF66" value="">
这是我的 jQuery ,它无效。
$('input:disabled').hover(
function(){
alert("hello");
},
function(){
alert("bye");
}
);
任何人都可以建议我如何实现这一目标。
答案 0 :(得分:2)
您可以将输入框括在div中,并在div的hove上引发警报。我尝试了它,它的工作非常完美。
<div id="hov"><input type="text" class="dcol" data-toggle="popover" data-content="Required Field with Numeric Input" disabled="disabled" style="background-color:#FFFF66" value=""></div>
$('#hov').hover(function(){
alert("hello");
});
我希望这能解决你的问题。
答案 1 :(得分:1)
它是由jQuery故意完成的。请参阅jQuery的this bug
这是在基于#6911的jQuery.event.dispatch中故意完成的 规范化跨浏览器行为。然而,它似乎是不可取的 我们这样做,至少对一些事件来说。我们可以很容易地恢复 改变,但它会导致其他错误报告。
答案 2 :(得分:1)
禁用字段不会触发鼠标事件。您可以做的是将一个元素放在禁用字段的前面,并将鼠标事件放在该元素上。
This will tell you exactly how to do it
但是,您可以做的其他事情是保持字段启用并将鼠标悬停在上面,禁用它并显示警报消息。像:
$('input').hover(function(){
alert("hello");
$(this).attr('disabled','disabled');
});
答案 3 :(得分:0)
我通过添加包装器并在包装器上添加悬停,然后在禁用时在层下设置按钮的z-index来解决按钮问题。有点痛苦,但似乎效果很好: 我对其进行了测试,该解决方案适用于所有其他禁用的表单元素,例如input / textarea。
Options +FollowSymlinks
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
答案 4 :(得分:-1)
试试这个 // HTLM
<input id="txt" type="text" class="dcol" data-toggle="popover" data-content="Required Field with Numeric Input" style="background-color:#FFFF66" value="">
// SCRIPT
$("#txt").hover(function(){
alert("this field will be automatically populated!");
$(this).attr('disabled','disabled');
});