I have this jQuery script:
<script type="text/javascript">
$(document).ready(function{
$("#btnLogon").bind("click", function(){
$("#btnLogon").after('<span class="error">Please wait...</span>');
});
});
</script>
In Firebug I get the error message
missing ( before formal parameters
What am I doing wrong here?
I have this jQuery script:
<script type="text/javascript">
$(document).ready(function{
$("#btnLogon").bind("click", function(){
$("#btnLogon").after('<span class="error">Please wait...</span>');
});
});
</script>
In Firebug I get the error message
missing ( before formal parameters
What am I doing wrong here?
Share Improve this question edited Feb 25, 2014 at 19:41 Eric Leschinski 154k96 gold badges422 silver badges336 bronze badges asked Apr 6, 2011 at 15:00 arame3333arame3333 10.2k27 gold badges129 silver badges214 bronze badges 03 Answers
Reset to default 15$(document).ready(function{
should be
$(document).ready(function(){
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$("#btnLogon").bind("click", function(){
$("#btnLogon").after('<span class="error">Please wait...</span>');
});
});
</script>
You were missing the parentheses after function
, on the second line.
You're missing the empty parameter list in the anonymous function for the ready handler on the document.
You can also use click()
as a shortcut to bind()
.
You can also use event.target
in your handler function, rather than select from the DOM again.
$(document).ready(function(){
$("#btnLogon").click(function(e){
$(e.target).after('<span class="error">Please wait...</span>');
});
});