Created
September 6, 2017 10:07
-
-
Save sksundram/30e0c49670bae255772285814312d9c5 to your computer and use it in GitHub Desktop.
List of some jQuery functions scrapped from the jQuery tutorial on FCC
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
/* jQuery functions */ | |
// ready function | |
$(document).ready(function() { | |
// put your code here | |
}); | |
addClass() | |
$("#target4").addClass("animated bounce"); // selecting using id name | |
removeClass() | |
$("button").removeClass("btn-default"); // selecting using tag name | |
remove() | |
$(".target").remove(); // completely removes from the DOM the element with class="target" // selecting using class name | |
html() | |
$("h3").html("<em>Hello</em>"); // will emphasize the text inside h3 tag | |
text() | |
$("h3").text("Hello again!"); // will only alter the text and not any HTML tag | |
.css() | |
$(".btn").css("color", "red"); // changes the css of an element with class="btn" | |
.prop() | |
$("#target3").prop("disabled", "true"); // changes the property of button with id="target3" so that it becomes unclickable | |
appengTo() | |
$("#target2").appendTo("#right-well"); // move button with id="target2" at the end of #right-well element | |
clone() | |
$("#target5").clone().appendTo("#left-well"); // first copy the element with id="target5" then append // function chaining | |
.parent() | |
$("#target1").parent().css("background-color", "red"); // targets only the parent element | |
.children() | |
$("#right-well").children().css("color", "orange"); // targets all the children elements | |
:nth-child(n) | |
$(".target:nth-child(2)").addClass("animated bounce"); | |
:even | |
$(".target:even").addClass("animated shake"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment