JQuery's difference between val and atrr (& quot; value & quot;, value assignment, jqueryatrr

Source: Internet
Author: User

JQuery has different values for val and atrr ("value", jqueryatrr

When I was working on a project, the data I passed from the background assigned a value to a text box. In the google browser,

No modification was found during the modification, and the reason was finally checked. It turns out that val and atrr ("value" in jQuery are different from those in browsers,

The summary is as follows:

In jquery, val () and atrr ('value' are used. If there is a default value, if val () is used to assign a value, when this value is modified, google cannot obtain the latest value, but ie can,
For atrr ('value', if there is a default value, ie and google can get the latest changes when it is worthwhile to change this value. Currently, tests are conducted on ie and google, and tests are not performed on other browsers. Haha


In jquery, $ (this) val (); is different from thisvalue.

$ (This). val (); there are four overloaded versions
Val () obtains the current value of the First Matching Element.
Val (array) check, select, radio, etc.
Val (function (index, value) sets the value of each matching element.
Val (val) sets the value of each matching element.

This. value gets the dom object value, such as text radio checkbox select.

Jquery $ ("# someid") val (); what is the difference with $ ("some") value? It turned out to be different from debugging to debugging at today?

$ ("# Someid"). val (); this is the jQuery method.
$ ("Some"). value; this does not seem like a jQuery Method

The "$" character is used in jQuery, but not necessarily "$" is jQuery.

For example, "$" in $ ("some"). value ",
I guess it is defined as follows:
Var $ = function (id ){
Return document. getElementById (id );
}

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.