In scripts written in jQuery I always come across a function that is the ready()
function, as the first function to be executed, see an example illustration of it:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scripttype="application/javascript">
$(document).ready(function () {
$("#btnexemplo").click(function () {
alert("meow");
});
});
</script>
<button id="btnexemplo">Click aqui!</button>
The function ready()
seems to belong to $(document)
, I do not know if it is an object, and if I remove it the click event does not fire.
So, I'd like to know what the purpose of the ready()
function is and how important is it to scripts written using the jQuery library?