@@ -35,9 +35,7 @@ many JavaScript programmers wrap their code in an `onload` function:
3535
3636```
3737window.onload = function() {
38-
3938 alert("welcome");
40-
4139}
4240```
4341
@@ -47,23 +45,17 @@ known as the [ ready event ](http://api.jquery.com/ready):
4745
4846```
4947$( document ).ready( function() {
50-
5148 // Your code here
52-
5349});
5450```
5551
5652For example, inside the ` ready ` event, you can add a click handler to the link:
5753
5854```
5955$( document ).ready(function() {
60-
6156 $("a").click(function( event ) {
62-
6357 alert("Thanks for visiting!");
64-
6558 });
66-
6759});
6860```
6961
@@ -76,15 +68,10 @@ you can prevent the default behavior by calling `event.preventDefault()` in the
7668
7769```
7870$( document ).ready(function() {
79-
8071 $("a").click(function( event ) {
81-
8272 alert("As you can see, the link no longer took you to jquery.com");
83-
8473 event.preventDefault();
85-
8674 });
87-
8875});
8976```
9077
@@ -106,19 +93,12 @@ and load it on the page with a `<script>` element's `src` attribute.
10693 <a href="http://jquery.com/">jQuery</a>
10794 <script src="jquery.js"></script>
10895 <script>
109-
11096 $( document ).ready(function() {
111-
11297 $("a").click(function( event ) {
113-
11498 alert("The link will no longer take you to jquery.com");
115-
11699 event.preventDefault();
117-
118100 });
119-
120101 });
121-
122102 </script>
123103 </body>
124104</html>
@@ -162,11 +142,8 @@ For example, if you create a click handler of:
162142
163143```
164144$("a").click(function( event ){
165-
166145 event.preventDefault();
167-
168146 $( this ).hide("slow");
169-
170147});
171148```
172149
@@ -217,9 +194,7 @@ Note the use of `function() {`. The anonymous function does exactly one thing:
217194
218195```
219196 $.get( "myhtmlpage.html", function() {
220-
221197 myCallBack( param1, param2 );
222-
223198 });
224199```
225200
0 commit comments