jquery, write something.

Source: Internet
Author: User

Find the P element under all div ... $ ("div>p");

Set page background color ... $ (document.body). CSS ("Background", "Black");

Hide all elements in a form ... $ (myform.elements). Hide ();

>>>>>>>>> in the first form of the document, look for all radio buttons (that is, input elements of type value radio) ... $ ("Input:radio", Document.forms[0]);

In an XML document returned by Ajax, find all the DIV elements ... $ ("div", Xml.responsexml)

dynamically creates a DIV element (and all its contents) and appends it to the BODY element. Inside this function, it is possible to implement markup to DOM element transformations by temporarily creating an element and setting the InnerHTML property of the element to the given tag string.

$("<div><p>Hello</p></div>").appendTo("body");

>>>>>>>>> Create a <input> element must also set the Type property. Because Microsoft specifies that the type of the <input> element can only be written once.

// 在 IE 中无效:$("<input>").attr("type", "checkbox");// 在 IE 中有效:$("<input type=‘checkbox‘>");

>>>>> dynamically creates a DIV element (and all of its contents) and appends it to the BODY element. Inside this function, it is possible to implement markup to DOM element transformations by temporarily creating an element and setting the InnerHTML property of the element to the given tag string.

$("<div>", {  "class": "test",  text: "Click me!",  click: function(){    $(this).toggleClass("test");  }}).appendTo("body");

>>>>>>>> creates a <input> element, setting the Type property, the property value, and some events.

$("<input>", {  type: "text",  val: "Test",  focusin: function() {    $(this).addClass("active");  },  focusout: function() {    $(this).removeClass("active");  }}).appendTo("form");



jquery, write something.

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.