Introduction to jquery the next day

Source: Internet
Author: User

3 selector: Element selector: $("button") , class selector: $(".btn") , ID selector: $("#target1") .

<Script>$ (document). Ready (function() {    $("Button"). addclass ("Animated Bounce"); $(". Well"). addclass ("animated Shake"); $("#target3"). addclass ("animated FadeOut"); $("Button"). Removeclass ("Btn-default");
$ ("button"). Remove ("#target4"); });</Script>

jquery has a .css() method called that allows you to change the CSS style of an element.

Here's how we're going to change the color to blue:

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

This is a bit different from the usual CSS syntax, where the properties and values of CSS are enclosed in quotation marks and separated by commas.

Let's try moving elements from one div to the other div .

jquery has a appendTo() way to add selected elements to other elements.

For example, if you want to target4 move from our right-well to left-well , we can use this:

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

In addition to moving elements, you can also copy elements. Simple to understand: Moving an element is cut, copying the element is copying.

The jquery clone() method can copy elements.

For example, if I want target2 to left-well copy from to right-well , we can write this:

$("#target2").clone().appendTo("#right-well");

Have you found that two jquery methods are used together? This is called the method chain function chaining , easy to use.

<Script>$ (document). Ready (function() {    $("#target1"). CSS ("Color", "Red"); $("#target1"). Prop ("Disabled", true); $("#target4"). Remove (); $("#target2"). AppendTo ("#right-well"); $("#target5"). Clone (). AppendTo ("#left-well"); });

The jquery .html() method can add HTML tags and text to an element, and the content before the element is replaced by the contents of the method.

We use em the [emphasize] tab to rewrite and emphasize the title text:

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

JQuery also has a similar method called .text() , which can only change the text but cannot modify the tag. In other words, this method only displays anything that comes in (including tags) as text.

Introduction to jquery the next day

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.