This file contains hidden or 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
// Setting CSS properties. | |
$( "h1" ).css( "fontSize", "100px" ); // Setting an individual property. | |
// Setting multiple properties. | |
$( "h1" ).css({ | |
fontSize: "100px", | |
color: "red" | |
}); |
This file contains hidden or 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
// Viewing the number of <h1> tags on the page. | |
var allHeadings = $( "h1" ); | |
alert( allHeadings.length ); |
This file contains hidden or 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
// The .html() method used as a setter: | |
$( "h1" ).html( "hello world" ); | |
// The .html() method used as a getter: | |
$( "h1" ).html(); |
This file contains hidden or 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
$( "#myId" ); // Note IDs must be unique per page. | |
$( ".myClass" ); |
This file contains hidden or 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
$( "a" ).attr( "href" ); // Returns the href for the first a element in the document |
This file contains hidden or 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
<!-- Putting jQuery into no-conflict mode. --> | |
<script src="prototype.js"></script> | |
<script src="jquery.js"></script> | |
<script> | |
var $j = jQuery.noConflict(); | |
// $j is now an alias to the jQuery function; creating the new alias is optional. | |
$j(document).ready(function() { | |
$j( "div" ).hide(); |
This file contains hidden or 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
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> | |
<script> | |
$( document ).ready(function() { | |
console.log( "document loaded" ); | |
}); | |
$( window ).load(function() { | |
console.log( "window loaded" ); |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Demo</title> | |
</head> | |
<body> | |
<a href="http://jquery.com/">jQuery</a> | |
<script src="jquery.js"></script> | |
<script> |
This file contains hidden or 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
break | |
case | |
catch | |
class | |
const | |
continue | |
debugger | |
default | |
delete | |
do |
This file contains hidden or 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
// Stopping a loop | |
for ( var i = 0; i < 10; i++ ) { | |
if ( something ) { | |
break; | |
} | |
} |