About jquery Gets the properties and values of an object

Source: Internet
Author: User
Tags tag name

1. Common ways to get objects

$ ("*") means get all objects ( not normally used )

$ ("#XXX") ' Get id=xxx Element Object ( common )

< Span style= "Color:rgb (75,75,75); Font-family:arial, song body; font-size:16px; Line-height:19.5px "> $ (". XXX") ' acquired class= Element object of XXX ( Common)

$ ("div") ' tag Selector selects all div elements (common)

$ ("Input[name= ' uname ')") gets the element object of the input tag name= 'uname' (Common)

Such as:

Self.find ("Input[name= ' Complany ')"). CSS (' border ', ' #FFB240 1px solid '), Self.find ("Textarea[name= ' Messcont ']"). css (' Border ', ' #FFB240 1px solid ');

The above selection method can be spaces with greater than sign >, plus + and tilde ~Used in combination, about the use of rules, you can refer to here (http://blog.csdn.net/hsd2012/article/details/51750105) in this blog, forgot to add the use of a comma combination, here is a case with a comma combination
To obtain a div with class message, the code is as follows:
<div class= "message" >gegrew</div><span class= "message" >ageaw</span><script type= "text/ JavaScript "src=" js/jquery-1.7.1.min.js "></script><script type=" Text/javascript ">console.log ($ (". Message,div "). html ());</script>




2. Other object acquisition methods$ ("Element[attribute = ' Ceshi ']") get all elements with a property of Ceshi
$ ("Element[attribute! = ' Ceshi ']") gets all elements that have a property that is not Ceshi
$ ("Element[attribute ^= ' Ceshi ')" gets all elements that have a property that is not the beginning of the Ceshi
$ ("Element[attribute *=' Ceshi ']" ' gets all elements that contain the beginning of the Ceshi of a property
<span class= "message" src= "Hello" >hello</span><span class= "message" src= "Byebye" >byebye</span ><script type= "Text/javascript" src= "js/jquery-1.7.1.min.js" ></script><script type= "text/ JavaScript ">console.log ($ (" span[src = ' Hello '] "). HTML ());</script>


3. Get the properties of an object $ ("element"). attr (Key) Gets the properties of an element
$ ("element"). attr (Key,value) sets a property for an element


























About jquery Gets the properties and values of an object

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.