Does a click event always need to be placed inside (document).ready(function() as example below because I have seen click(function() located outside of it and I am wondering how to do it can be done
$(document).ready(function(){
$('#checkout').click(function() {
alert("Thanks for visiting!");
});
});
It doesn’t need to be in a
$(document).ready();. It’s the same as any javascript. It needs to be placed either after the elements it will be accessing, or in a$(document).ready();. If you put your script directly after the element you want add a click event to you can speed up your page: http://encosia.com/dont-let-jquerys-document-ready-slow-you-down/