Disabling radio buttons with jQuery

前端 未结 8 649
鱼传尺愫
鱼传尺愫 2020-12-05 01:28

I\'m trying to disable these radio buttons when a the loadActive link is clicked but for some reason it only disables the first in the order and then skips the rest.

8条回答
  •  囚心锁ツ
    2020-12-05 02:26

    I've refactored your code a bit, this should work:

    jQuery("#loadActive").click(writeData);
    
    function writeData() {
        jQuery("#chatTickets input:radio").attr('disabled',true);
    }
    

    If there are more than two radio buttons on your form, you'll have to modify the selector, for example, you can use the starts with attribute filter to pick out the radios whose ID starts with ticketID:

    function writeData() {
        jQuery("#chatTickets input[id^=ticketID]:radio").attr('disabled',true);
    }
    

提交回复
热议问题