jquery Usage Summary

Source: Internet
Author: User

This week is doing front-end page development, with jquery knowledge more, convenient later use, do a small summary of it.

Empties all child elements under an element:

$ ("#tickey_content"). empty ();

Loop value:

$.each (contents, function (I, item) {       
Gets the text inside the LABEL element:

$ ("#role"). Text ()

Set the text inside the LABEL element:

<pre name= "Code" class= "JavaScript" >$ ("#role") <span style= "font-family:arial, Helvetica, Sans-serif;" >.html (UserName);</span>

Get the text inside the TEXTAREA element:

$ ("#reply"). Val ();
Empty the text inside the TEXTAREA element:

$ ("#reply"). Val ("");
jquery may be an element:

$ ("#content_template"). Clone ();

Gets the first child element under an element:

Templatediv.children (": First");

Gets the next element of an element:

Templatediv.next ();
Gets the last element under an element:

Contenttemplate.children (": Last");

Delete an attribute of an element, such as an ID:

To add a CSS property to an element:

Templatediv.css (' Display ', ' block ');

Add a class attribute to an element:

Divelement.addclass ("Engineerstyle");

Add the href attribute to the A tag:

$ ("#aElement"). attr ("href", "${ctx}" +filepath+filename);
Add a new element under an element:

$ ("#tickey_content"). Append (Templatediv);
Add an element to the front of an element:

Divelement.prepend (content);

The JS string determines whether a character is included:

Role.indexof (' engineer ') >=0











jquery Usage Summary

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.