开发者

jquery missing ) after argument list on radiobutton form

开发者 https://www.devze.com 2023-03-05 13:18 出处:网络
I copied a pice of jquery code from a tutorial for working with radio buttons. It is not working for me but from the comments on the tutorial it seems to work for other people. I get this \"missing )

I copied a pice of jquery code from a tutorial for working with radio buttons. It is not working for me but from the comments on the tutorial it seems to work for other people. I get this "missing ) after argument list" } else { So here is the relevant portion of my code. I have two radio buttons above two forms. I want to show the form with the checked radio button and hide the other form.

    <script type="text/javascript">
        $(document).ready(function() {
          $('#existing-login').show();
          $('#new-customer').hide();
        });

        $("input[@name='customer']").change(function(){
            if ($("input[@name='customer']:checked").val(开发者_如何学C) == "new")
                $("#new-customer").show();
                $("#existing-login").hide();
            } else {
                $("#existing-login").show();
                $("#new-customer").hide();
            }
        });
    </script>

   <input type="radio" name="customer" value="existing" checked="checked"/>
   <input type="radio" name="customer" value="new"/>

        <div id="existing-login">
            <!-- form for existing customer login -->
        </div>
        <div id="new-customer">
            <!-- form for new customers -->
        </div>


Missing { after your if statement:

if ($("input[@name='customer']:checked").val() == "new") {
    $("#new-customer").show();
    $("#existing-login").hide();
} else {
    $("#existing-login").show();
    $("#new-customer").hide();
}

Also the @ syntax for selecting attributes isn't supported anymore in current versions of jQuery, so remove that too:

if ($("input[name='customer']:checked").val() == "new") {
0

精彩评论

暂无评论...
验证码 换一张
取 消