The checked most important concept about a property is that you have to remember that it has nothing to do with checked the state value, setting or setting the checked = "checked" checked = "true" property, and its state value true/false is
This example describes the use of attr () and prop () functions in jquery. Share to everyone for your reference, specific as follows:
attr () Method of jquery
jquery uses the attr () method to get and set element attributes, attr is the
jquery Get Custom properties (attr and prop) instance introduction font: [Increase decrease] type: Reprint
jquery uses the attr () method to get and set element properties, attr is an abbreviation for attribute (attribute), which is often used
In JS, set the attribute and attribute value of the node to setattribute (), get the attribute and attribute value of the node used to GetAttribute (), and in jquery, with a attr () can be all done, praise a first ^^jquery uses the attr () method to
"To summarize yourself, see the transcript below for details":attr () is used to manipulate HTML properties, and the prop () property is used to manipulate DOM properties①: In many cases, it can be interoperable②:attr () for cases where custom HTML
. attr (), this method has been in existence since jq1.0, the official document writes the function is reads/writes the DOM attribute value, actually before 1.6 sometimes is attribute, sometimes is the property.. Prop (), this method jq1.6
$ ("Form "). attr ("check"); $ ("form "). prop ("check"); both of them are acceptable, but the new version of jquery recommends the second one. Both of them are similar in other aspects. The only difference I found is that in checkbox, you need to
$ ("form"). attr ("check"); $ ("form"). Prop ("check"); Both can, but the new version of jquery recommended the second, two in other respects are similar, I found that the only difference is on the checkbox, need to use prop, or IE browser will not
// Traverse option and add or remove Option
Function changeshipmethod (shipping ){
VaR Len = $ ("select [@ name = ishiptype] Option"). Length
If (Shipping. value! = "Ca "){
$ ("Select [@ name = ishiptype] Option"). Each (function (){
If ($ (this).
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.