jquery missing ) after argument list on radiobutton form
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") {
精彩评论