1

私はこのコードを持っていますが、うまくいきません。問題は何でしょうか?私の構文が間違っていますか、それともメソッド全体が間違っていますか?

<input checked="checked" class="form-field" id="IsCurrentlySmokingrightNej" name="IsCurrentlySmokingright" type="radio" value="Nej">
<input class="form-field" id="IsCurrentlySmokingrightJa" name="IsCurrentlySmokingright" type="radio" value="Ja">
    <input id="IsCurrentlySmokingrighttextbox" name="IsCurrentlySmokingright" type="text" style="background-color: rgb(0, 255, 0); float: right; width: 50px;">

JavaScript:

 $(document).on("change", "IsCurrentlySmokingrightNej", function() {
    var elem = document.getElementById("IsCurrentlySmokingrightNej");
    var ele = $("#IsCurrentlySmokingrighttextbox");
    if (elem.checked) {
        ele.css("background-color", "rgba(0, 255, 0, 1)");
        ele.css("float", "right");
        ele.css("width", "50px");

    }
});

   $(document).on("change", "IsCurrentlySmokingrightJa", function() {
        var elem = document.getElementById("IsCurrentlySmokingrightJa");
        var ele = $("#IsCurrentlySmokingrighttextbox");
        if(elem.checked){
            ele.css("background-color", "rgba(255, 0, 0, 1");//röd
            ele.css("float", "right");
            ele.css("width", "50px");
        }

});
4

2 に答える 2