简体   繁体   中英

Radio button click event not firing for the first time in Firefox

Radio button click event not firing for the first time,but firing on second click in firefox, but it works well in IE, Chrome:

if ($("#div-1").children().length == 1 && $("#div-1").find(':radio').length >= 1) {

    $("#done-button").hide();

    $("#div-1").find(':radio').on("click", function () {

        console.log("clicked");

        $("#done-button").click();

    });

}

You can try using:

$('input:radio') 

// or $("input[type='radio']")

Suggestion from jQuery docs

It is recommended to precede :radio with a tag name or some other selector; otherwise, the universal selector ("*") is implied. In other words, the bare $( ":radio" ) is equivalent to $( " *:radio" ), so $( "input:radio" ) should be used instead

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