Skip to content

Commit

Permalink
Create jQueryDestructiveMethods.html
Browse files Browse the repository at this point in the history
  • Loading branch information
omgitskuei committed Apr 21, 2021
1 parent 14d53d6 commit 0025592
Showing 1 changed file with 35 additions and 0 deletions.
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>

0 comments on commit 0025592

Please sign in to comment.