How to alert the defined function in jquery

This question already has an answer here:

  • How can I know which radio button is selected via jQuery? 29 answers

  • You can test whether a specific one is checked using jQuery as follows:

    if ($("#radio1").prop("checked")) {
       // do something
    }
    
    // OR
    if ($("#radio1").is(":checked")) {
       // do something
    }
    
    // OR if you don't have ids set you can go by group name and value
    // (basically you need a selector that lets you specify the particular input)
    if ($("input[name='radioGroup'][value='1']").prop("checked"))
    

    You can get the value of the currently checked one in the group as follows:

    $("input[name='radioGroup']:checked").val();
    
    链接地址: http://www.djcxy.com/p/24586.html

    上一篇: 我怎么知道在jQuery中选择了哪个无线电输入?

    下一篇: 如何提醒jQuery中定义的函数