-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create jQueryDestructiveMethods.html
- Loading branch information
1 parent
14d53d6
commit 0025592
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
JavascriptDev/src/main/resources/static/notes/js/jQuery/jQueryDestructiveMethods.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
<p></p> | ||
|
||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | ||
|
||
<script> (function ($) { | ||
// Sets the <p></p> innerText to "JQuery text" and then returns $('p'). | ||
var thing1 = $('p').text('jQuery text'); | ||
// print the <p></p> on console | ||
console.log(thing1); // init [p, prevObject: init(1), context: document, selector: "p"] | ||
console.log($('p')); // init [p, prevObject: init(1), context: document, selector: "p"] | ||
|
||
// .text() returns | ||
var theText = $('p').text('jQuery').text(); // Returns the string "jQuery". | ||
|
||
alert(theText); | ||
|
||
// Cannot chain after text(). The chain is broken. | ||
|
||
// A string is returned, not the jQuery object. | ||
|
||
})(jQuery)</script> | ||
</body> | ||
|
||
</html> |