Jquery DOC Ready Function

Basic jQuery document ready snippet

First part is the jQuery library call. Then the doc ready code below it. I realize this is super basic but I copy paste everything. I don’t trust my memory and certainly don’t trust my spelling so I live by the paste. I threw in a click function just because it’s almost a guarantee I use it in every page script.


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>


<script>	

$(document).ready(function() { //12PM DOC READY
		 
  $( ".myClass" ).click(function() {
    var button_id = $(this).attr("data-id");
    alert(button_id);
  });

}); //12PM DOC READY

</script>

Comments