Jquery Introduction 2

Source: Internet
Author: User

Last time I discussed the basics and introduction of Jquery, and listed some basic selectors, basic selectors and level selectors. Now I will discuss with you other commonly used selectors in Jquery, by learning multiple selectors of Jquery, you may find that Jquery is a very powerful html Dom Query Library. Jquery provides many DOM query methods, it is a simple way for us to change Dom operations, so we don't have to worry about it. If we find a specific target, let's go into the Jquery selector.
Filter selector:
: First $ ("div: first") Select the first element of all DIV elements
: Last $ ("div: last") Select the last element of all div elements
: Not (selector) $ ("input: not (. myClass)") gets the Input element of a class not called myClass.
: Even $ ("input: even") gets the Input element whose index is an even number.
: Odd $ ("input: odd") elements of the Input whose index is an odd number
: Eq $ ("input: eq (2)") gets the subscript index 2 of all input elements.
: Gt $ ("input: gt (1)") obtains the element whose subscript index is greater than 1 in the input element.
: Lt $ ("input: lt (1)") to obtain the element whose subscript index is less than 1 in the input element
: Header $ ("header") to get all Content Filter Selector
: Contains (text) $ ("div: contains (me)") select text that contains "my" My div elements
: Empty $ ("div: empty") Select a div element that does not contain child elements, but includes text elements.
: Has $ ("div: has (p)") Select the div element containing the p element
: Parent $ ("div: parent") Select the div element with sub-elements
Attribute filter selector www.2cto.com
[Attribute] $ ("div [id]") returns the element with the id attribute of the div.
[Attribute = value] $ (div [title = 'sharme ']) Obtain an element whose attribute is title and whose value is sharme.
[Attribute! = Value] $ (div [title! = 'Sharme ']) elements whose attribute title value is not sharme
[Attribute ^ = 'value'] $ ("div [title ^ = 'sha']") obtain the element whose attribute title value starts with sha
[Attribute $ = 'value'] $ ("div [title $ = 'me']") gets the element of the div whose attribute is the title value ending with me
[Attribute * = 'value'] $ ("div [title * = 'ss']") obtain all div elements whose attributes are sss and whose values are title.
Comprehensive Practice: $ ("div [title = 'sharme '] [name ^ = 'sha'] [class $ = 'me']") obtains the title as sharme in sequence, element of the div whose name starts with sha and whose class value ends with me
 

Next we will discuss the DOM operations, functions in jquery.
Append () First append content to each element
AppendTo () attaches content to the element $ ("<div> sharme </div>"). appendTo ("p ")
Prepend () $ ("p"). preprend ("dddddddd") before appending ddddd to the p element
PrependTo () $ ("ddddddd"). preprendTo ("p ")
After ()
InsertAfter () $ ("<div> sharme <div/>"). insertAfter ("p") inserts an element after the p element
Before (); $ ("p"). before ("dddd"); before adding ddd to the p element
InsertBefore (); // $ ("dddd"). insertBefore ("p ");
 
The Jquery selector is listed here. Next time I will discuss with you about the event processing mechanism in Jquery and share my experience. If you are interested, I hope you will pay more attention to my blog, I have just started to write a blog. I will keep updating my blog and share my technology here.

 

From sharme's column

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.