Attribute operations in the jquery tag, jquery tag

Source: Internet
Author: User

Attribute operations in the jquery tag, jquery tag

. Arrt ()
Obtains the attribute values of the first element in a matched element set, or sets one or more attribute values of each element.
. Attr (attributeName)
$ ("Em"). attr ("title ");
Q: Obtain the title value of the first em in the "em" set.
. Attr (attributeName, value)
Attribute name to be set for attributeName
Value
$ ("# Greatp"). attr ('alt', 'she zhi shu xing zhi ')
Set the alt value of this element

. Attr (attributes)
Set attribute values
$ ("Greatp"). attr ({
Alt: "she alt de zhi"
Title: "she title de zhi"
})
. Attr (attributeName, function (index, attr ))
Attribute name to be set for attributeName
Function (index, attr)
This function returns the value to be set. this indicates the current element. The received index parameter indicates the index of the element in the matched element.
$ ("Img"). attr ("src", function (){
Return "/resources/" + this. title;
})
. Prop ()
Obtain the attribute values of the first element in the matching element set or set one or more attribute values of each matching element.
. Prop (propertyName)
Obtains the attribute value of the first element in a matched element.
PropertyName: the name of the property to be obtained.
. Prop (propertyName, value)
PropertyName: name of the property to be set
Value is a value to set the attribute value.
$ ("Input [type = 'checkbox']"). prop ({
Disabled: true
})
Disable all check boxes on the page.
. Prop (propertyName, function (index, oldpropertyValue ))
Name of the property to be set
Function is a function that returns the value to be set.
. RemoveAttr ()
Removes an attribute from each element of a matched element set.
. RemoveAttr (attributeName)
AttributeName: name of the attribute to be removed
Input. removeAttr ("title ")
Remove the title attribute above input.
. RemoveProp (propertyName)
Deletes an attribute for the matching element in the set.
PropertyName: the name of the property to be removed.
Input. removeProp ("title ")
Remove the title attribute above input.
. Val ()
Obtain the current value of the first element in the matched element set or set the value of each element in the matched element set.
. Val () gets the current value of an element in the matched element set. This method does not accept any parameters.
$ ("# Single"). val (); get the value of this form.
$ ("Input"). keyup (function (){
Var value = $ (this). val ();
$ ("P"). text (value );
}). Keyup ();
In this input, each time the keyboard is lifted, the value is obtained and rendered in the p tag.
. Val (value)
Set the value of each element in the matched element set.
Value is a text string, a number, or an array in the form of a string.
$ ("Button"). click (function (){
Var text = $ (this). text ();
$ ("Input"). val (text );
}); When you click the button, obtain the text of the current button and set it to the input value.
. Val (function)
A function used to return the set value. this points to the current element.

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.