Reputation: 11265
<script>
function showAlert(){
alert('Bazinga')
}
$(document).ready(function(){
showAlert();
});
</script>
In my example I first of all declaring function and else calling this function when documents is loaded. But alert is now show.
Upvotes: 0
Views: 125
Reputation: 115212
Make sure you have included jQuery library , The script should be after the jQuery library.
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script>
function showAlert(){
alert('Bazinga');
}
$(document).ready(function(){
showAlert();
});
</script>
Upvotes: 1
Reputation: 21
I think you forgot the ";" on alert, try adding ";". If that does not do the trick you could try move up ur document ready.
Upvotes: 1