Start learning jQuery and preparation

<script>
$(document).ready(function(){

});

First, add a line at the top of the page scriptelement, and then write the next line terminator.

The browser will run scriptin all Javascript, including jQuery.

In your scriptelement inside, add this code: $(document).ready(function() {to you script, and then the next line by });the end of it.


Use the same operation jQuery selector element

<script>
$(document).ready(function() {
$("button").addClass("animated");
$(".btn").addClass("shake");
$("#target1").addClass("btn-primary");//首选项
});
</script>

HTML elements using jQuery to change the CSS style

$("#target1").css("color", "blue");

Use jQuery element disposed unavailable

$("button").prop("disabled", true);

Use jQuery to change the text element

$("h3").html("<em>jQuery Playground</em>");

To delete an HTML element using jQuery

 $("#target4").remove();

using the appendTo jQuery () moving HTML element

$("#target4").appendTo("#left-well");

Use jQuery clone () method to copy element

$ ( "# TARGET2") .clone () .appendTo ( "# right-Well"); // two methods together using jQuery? This method is called chainfunction chaining

To target2from left-wellcopy to right-well,

Use jQuery parent () operation parent element

$("#left-well").parent().css("background-color", "blue")

Use jQuery children () operation to child elements,

$("#left-well").children().css("color", "blue")

 

jQuery using target: nth-child (n) CSS selectors acquisition sub-elements

$(".target:nth-child(3)").addClass("animated bounce");

// The following code shows how to jQuery Playground of each well (left well and right well) is three child element bounce categories:

jQuery even-indexed using the selected operating element

$(".target:even").addClass("animated shake"); //偶数

$(".target:odd").addClass("animated shake");//奇数

Modify the entire page using jQuery

$ ( "Body") addClass ( "animated fadeOut");. // whole body fade out effect

$ ( "Body") addClass ( "animated hinge");. // upper left corner of a rock fall as the center clockwise fade

 

Guess you like

Origin www.cnblogs.com/chendi618/p/11012975.html