Professional Documents
Culture Documents
Online JQuery Cheat Sheet2
Online JQuery Cheat Sheet2
com/jquery/
Hide comments
jQuery CheatSheet
Basics Selectors
$("*") // all elements
Include $("p.demo") // <p> elements with class="int
Events
Download $("p:first") // the first <p> element
$(".demo").click(function(){ <script src="https://code.jquery.com/jquery-latest.min.js" type="text/javascript"
$("p span") // span, descendant of p
$(this).hide(200); $("p > span")
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></ // span, direct child of p
}); $("p + span") // span immediately proceeded b
$("p ~ span") // strong element proceeded by
Syntax
Mouse $("ul li:first") // the first <li> element of th
$(document).ready(function(){ $("ul li:first-child") // the first <li> element of ev
scroll, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter,
$(".demo").click(function(){
mouseleave, load, resize, scroll, unload, error $("ul li:nth-child(3)") // third child
$(this).hide(200); $("[href]") // any element with an href att
Keyboard }); $("a[target='_blank']") // <a> elements with a target "
keydown, keypress, keyup }); $("a[target!='_blank']") // <a> elements with a target a
$(function(){ $(":input") // all form elements
Form // Short Document Ready $(":button") // <button> and <input> element
submit, change, focus, blur }); $("tr:even") // even <tr> elements
$("tr:odd") // odd <tr> elements
DOM Element Each
$("span:parent") // element which has child elem
blur, focus, focusin, focusout, change, select, submit $(".demo").each(function() { // parse each .demo element
$("span:contains('demo')") // element conaining the specif
document.write($(this).text() + "\n"); // output their text
Browser }); Actions
load, resize, scroll, unload, error $(selector).action()
Trigger
$(this).hide() // the current element
.bind() $("a#mylink").trigger("click"); // triggers event on an element
$("div").hide() // all <div> elements
$(document).ready(function() { // attach a handler to an event for the elements $(".demo").hide() // all elements with class="demo"
$("#demo").bind('blur', function(e) { noConflict $("#demo").hide() // the element with id="demo"
//dom event fired var jq = $.noConflict(); // avoid conflict with other frameworks also using the doll
}); jq(document).ready(function(){
}); jq("#demo").text("Hello World!");
}); Ads
$.post()
jQuery
$.post("demo.asp", jQuery UI HTTP POST
// send JS cleaner JS Obfuscator
request to a page and get the answer
{ Articles Can I use?
name: "John", // send data
age: 30
},
function(data, status){ //retreive response
console.log("Data: " + data + "\nStatus: " + status);
});
HTML Cheat Sheet is using cookies. | PDF | Terms and Conditions, Privacy Policy
© HTMLCheatSheet.com