[英]How to alert if user tries to click a disabled radio button
Is it possible for Jquery or Javascript to capture a click on a disabled radio button, and alert the user to do something else first. Jquery或Javascript是否有可能捕获对禁用的单选按钮的单击,并警告用户首先执行其他操作。 As far as I know, I could not find any way to capture a mouse over or click event on a disabled radio button.
据我所知,我找不到任何方法来捕获鼠标悬停或单击禁用的单选按钮上的事件。
Please advise if this is possible. 请告知是否可能。 Thanks.
谢谢。
Regards, Prakash 问候,Prakash
$('input[type="radio"][disabled]').click(function() {
alert('waffles');
});
jQuery doc reference: attribute-equals-selector ( [type="radio"]
), has-attribute-selector ( [disabled]
). jQuery doc参考: attribute-equals-selector (
[type="radio"]
), has-attribute-selector ( [disabled]
)。
If the radio buttons can be dynamically added, you'll need to use on
instead: 如果可以动态添加单选按钮,则需要改用
on
:
$(document).on('click', 'input[type="radio"][disabled]', function() {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.