简体   繁体   中英

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. 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

$('input[type="radio"][disabled]').click(function() {
    alert('waffles');
});

jQuery doc reference: attribute-equals-selector ( [type="radio"] ), has-attribute-selector ( [disabled] ).

If the radio buttons can be dynamically added, you'll need to use on instead:

$(document).on('click', 'input[type="radio"][disabled]', function() {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM