Skip to content

Commit 59f11c4

Browse files
committed
md cleanup
1 parent 887356f commit 59f11c4

File tree

4 files changed

+65
-35
lines changed

4 files changed

+65
-35
lines changed

content/jquery-fundamentals/using-jquery-core/avoid-conflicts-other-libraries.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ attribution: jQuery Fundamentals
66
---
77
## Avoiding Conflicts with Other Libraries
88

9-
If you are using another JavaScript library that uses the `$` variable, you can run into conflicts with jQuery.
10-
In order to avoid these conflicts, you need to put jQuery in no-conflict mode immediately after it is loaded onto the page and before you attempt to use jQuery in your page.
9+
If you are using another JavaScript library that uses the `$` variable, you can
10+
run into conflicts with jQuery. In order to avoid these conflicts, you need to
11+
put jQuery in no-conflict mode immediately after it is loaded onto the page and
12+
before you attempt to use jQuery in your page.
1113

12-
When you put jQuery into no-conflict mode, you have the option of assigning a variable name to replace `$`.
14+
When you put jQuery into no-conflict mode, you have the option of assigning a
15+
variable name to replace `$`.
1316

1417
<div class="example" markdown="1">
1518
Putting jQuery into no-conflict mode
@@ -19,8 +22,10 @@ Putting jQuery into no-conflict mode
1922
&lt;script>var $j = jQuery.noConflict();&lt;/script>
2023
</div>
2124

22-
You can continue to use the standard $ by wrapping your code in a self-executing anonymous function;
23-
this is a standard pattern for plugin authoring, where the author cannot know whether another library will have taken over the `$`.
25+
You can continue to use the standard $ by wrapping your code in a
26+
self-executing anonymous function; this is a standard pattern for plugin
27+
authoring, where the author cannot know whether another library will have taken
28+
over the `$`.
2429

2530
<div class="example" markdown="1">
2631
Using the $ inside a self-executing anonymous function
@@ -29,9 +34,9 @@ Using the $ inside a self-executing anonymous function
2934
&lt;script src="jquery.js">&lt;/script>
3035
&lt;script>
3136
jQuery.noConflict();
32-
37+
3338
(function($) {
3439
// your code here, using the $
3540
})(jQuery);
3641
&lt;/script>
37-
</div>
42+
</div>

content/jquery-fundamentals/using-jquery-core/dollar-object-vs-function.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,30 @@ attribution: jQuery Fundamentals
66
---
77
## $ vs $()
88

9-
Until now, we’ve been dealing entirely with methods that are called on a jQuery object. For example:
9+
Until now, we’ve been dealing entirely with methods that are called on a jQuery
10+
object. For example:
1011

1112
<div class="example" markdown="1">
1213
$('h1').remove();
1314
</div>
1415

15-
Most jQuery methods are called on jQuery objects as shown above;
16-
these methods are said to be part of the `$.fn` namespace, or the “jQuery prototype,” and are best thought of as jQuery object methods.
16+
Most jQuery methods are called on jQuery objects as shown above; these methods
17+
are said to be part of the `$.fn` namespace, or the “jQuery prototype,” and are
18+
best thought of as jQuery object methods.
1719

18-
However, there are several methods that do not act on a selection;
19-
these methods are said to be part of the jQuery namespace, and are best thought of as core jQuery methods.
20+
However, there are several methods that do not act on a selection; these
21+
methods are said to be part of the jQuery namespace, and are best thought of as
22+
core jQuery methods.
2023

21-
This distinction can be incredibly confusing to new jQuery users. Here’s what you need to remember:
24+
This distinction can be incredibly confusing to new jQuery users. Here’s what
25+
you need to remember:
2226

23-
* Methods called on jQuery selections are in the `$.fn` namespace, and automatically receive and return the selection as this.
24-
* Methods in the $ namespace are generally utility-type methods, and do not work with selections; they are not automatically passed any arguments, and their return value will vary.
27+
* Methods called on jQuery selections are in the `$.fn` namespace, and
28+
automatically receive and return the selection as this.
29+
* Methods in the $ namespace are generally utility-type methods, and do not
30+
work with selections; they are not automatically passed any arguments, and
31+
their return value will vary.
2532

26-
There are a few cases where object methods and core methods have the same names, such as `$.each` and `$.fn.each`. In these cases, be extremely careful when reading the documentation that you are exploring the correct method.
33+
There are a few cases where object methods and core methods have the same
34+
names, such as `$.each` and `$.fn.each`. In these cases, be extremely careful
35+
when reading the documentation that you are exploring the correct method.

content/jquery-fundamentals/using-jquery-core/feature-browser-detection.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@ attribution: jQuery Fundamentals
66
---
77
## Feature &amp; Browser Detection
88

9-
Although jQuery eliminates most JavaScript browser quirks, there are still occasions when your code needs to know about the browser environment.
9+
Although jQuery eliminates most JavaScript browser quirks, there are still
10+
occasions when your code needs to know about the browser environment.
1011

11-
jQuery offers the `$.support` object, as well as the deprecated $.browser object, for this purpose.
12-
For complete documentation on these objects, visit [http://api.jquery.com/jQuery.support/](http://api.jquery.com/jQuery.support/ "$.support documentation on api.jquery.com") and [http://api.jquery.com/jQuery.browser/](http://api.jquery.com/jQuery.browser/ "$.browser support on api.jquery.com").
12+
jQuery offers the `$.support` object, as well as the deprecated $.browser
13+
object, for this purpose. For complete documentation on these objects, visit
14+
[http://api.jquery.com/jQuery.support/](http://api.jquery.com/jQuery.support/
15+
"$.support documentation on api.jquery.com") and
16+
[http://api.jquery.com/jQuery.browser/](http://api.jquery.com/jQuery.browser/
17+
"$.browser support on api.jquery.com").
1318

14-
The `$.support` object is dedicated to determining what features a browser supports; it is recommended as a more “future-proof” method of customizing your JavaScript for different browser environments.
19+
The `$.support` object is dedicated to determining what features a browser
20+
supports; it is recommended as a more “future-proof” method of customizing your
21+
JavaScript for different browser environments.
1522

16-
The `$.browser` object was deprecated in favor of the `$.support` object, but it will not be removed from jQuery anytime soon. It provides direct detection of the browser brand and version.
23+
The `$.browser` object was deprecated in favor of the `$.support` object, but
24+
it will not be removed from jQuery anytime soon. It provides direct detection
25+
of the browser brand and version.

content/jquery-fundamentals/using-jquery-core/utility-methods.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ attribution: jQuery Fundamentals
66
---
77
## Utility Methods
88

9-
jQuery offers several utility methods in the $ namespace.
10-
These methods are helpful for accomplishing routine programming tasks.
11-
Below are examples of a few of the utility methods; for a complete reference on jQuery utility methods, visit [http://api.jquery.com/category/utilities/](http://api.jquery.com/category/utilities/ "Utilities documenations on api.jquery.com").
9+
jQuery offers several utility methods in the $ namespace. These methods are
10+
helpful for accomplishing routine programming tasks. Below are examples of a
11+
few of the utility methods; for a complete reference on jQuery utility methods,
12+
visit
13+
[http://api.jquery.com/category/utilities/](http://api.jquery.com/category/utilities/
14+
"Utilities documenations on api.jquery.com").
1215

1316
### $.trim
1417

@@ -36,7 +39,8 @@ Iterates over arrays and objects.
3639
<div class="note" markdown="1">
3740
### Note
3841

39-
There is also a method `$.fn.each`, which is used for iterating over a selection of elements.
42+
There is also a method `$.fn.each`, which is used for iterating over a
43+
selection of elements.
4044
</div>
4145

4246
### $.inArray
@@ -45,7 +49,7 @@ There is also a method `$.fn.each`, which is used for iterating over a selection
4549
Returns a value's index in an array, or -1 if the value is not in the array.
4650

4751
var myArray = [ 1, 2, 3, 5 ];
48-
52+
4953
if ($.inArray(4, myArray) !== -1) {
5054
console.log('found it!');
5155
}
@@ -58,18 +62,19 @@ Changes the properties of the first object using the properties of subsequent ob
5862

5963
var firstObject = { foo : 'bar', a : 'b' };
6064
var secondObject = { foo : 'baz' };
61-
65+
6266
var newObject = $.extend(firstObject, secondObject);
6367
console.log(firstObject.foo); // 'baz'
6468
console.log(newObject.foo); // 'baz'
6569
</div>
6670

6771
<div class="example" markdown="1">
68-
If you don't want to change any of the objects you pass to `$.extend`, pass an empty object as the first argument.
72+
If you don't want to change any of the objects you pass to `$.extend`, pass an
73+
empty object as the first argument.
6974

7075
var firstObject = { foo : 'bar', a : 'b' };
7176
var secondObject = { foo : 'baz' };
72-
77+
7378
var newObject = $.extend({}, firstObject, secondObject);
7479
console.log(firstObject.foo); // 'bar'
7580
console.log(newObject.foo); // 'baz'
@@ -78,26 +83,28 @@ If you don't want to change any of the objects you pass to `$.extend`, pass an e
7883
### $.proxy
7984

8085
<div class="example" markdown="1">
81-
Returns a function that will always run in the provided scope — that is, sets the meaning of this inside the passed function to the second argument.
86+
Returns a function that will always run in the provided scope — that is, sets
87+
the meaning of this inside the passed function to the second argument.
8288

8389
var myFunction = function() { console.log(this); };
8490
var myObject = { foo : 'bar' };
85-
91+
8692
myFunction(); // logs window object
87-
93+
8894
var myProxyFunction = $.proxy(myFunction, myObject);
8995
myProxyFunction(); // logs myObject object
9096
</div>
9197

9298
<div class="example" markdown="1">
93-
If you have an object with methods, you can pass the object and the name of a method to return a function that will always run in the scope of the object.
99+
If you have an object with methods, you can pass the object and the name of a
100+
method to return a function that will always run in the scope of the object.
94101

95102
var myObject = {
96103
myFn : function() {
97104
console.log(this);
98105
}
99106
};
100-
107+
101108
$('#foo').click(myObject.myFn); // logs DOM element #foo
102109
$('#foo').click($.proxy(myObject, 'myFn')); // logs myObject
103-
</div>
110+
</div>

0 commit comments

Comments
 (0)