The Value property of the Li tag in HTML is compatible with the problem

Source: Internet
Author: User

The Value property of the Li tag in HTML is compatible with each browser, and it is not recommended to use Li's value, type property.

Problem Description:

Inadvertently discovered that there was a problem assigning Li's Value property in the IE11 browser:

 <  ul     >  <  li  value  = ' 0098 '  > integer beginning with 0 is automatically erased  </ li     >  <  li  value  = ' 2147483648 '  > value greater than the maximum value defaults to maximum (IE11)  </ li  >  </ ul  >  

The above code assigns the Value property of Li to ' 0098 ' (a numeric string starting with 0) and ' 2147483648 ' (a numeric string that exceeds the maximum range of int)

But then the values are ' 98 ', ' 2147483647 ', respectively.

The reason is that some browsers, including IE, have internally processed the Value property of the LI tag: The Value property of the Li tag is automatically converted to the int numeric type, and the default value is 0;

Test Type

IE9, IE10, IE11

FireFox

Google

Positive integers

Normal (greater than 2147483647 display 2147483647)

Normal (greater than 2147483647 display 0)

Normal (greater than 2147483647 display 0)

Negative

Turn 0 (Use JS dynamic assignment will error)

Normal (less than-2147483647 display 0)

Normal (less than-2147483648 display 0)

Floating point number

Intercept integer part (JS dynamic assignment, if the previous value is not 0, then less than 1 of the floating-point number will be error)

Intercept the whole number of parts

Intercept the whole number of parts

Letters

Turn 1 (JS dynamic assignment will error)

Turn into 0

Turn into 0

Letters + Numbers

Turn 1 (JS dynamic assignment will error)

Turn 0 (if the number starts with the largest integer number)

Turn 0 (if the number starts with the largest integer number)

Chinese

Turn 1 (JS dynamic assignment will error)

Turn into 0

Turn into 0

Note: This test is valid only for the LI tag in HTML, and the other is not tested for the time being.

But the strange point is: in the use of JS dynamically generated on the LI element above these laws will not be applicable, here is no longer one by one test.

Therefore, when you want to apply the Value property of the Li tag, it is important to note that the Value property is not recommended. You can use other custom attributes instead, or you can consider the applicable $.data assignment in the case of jquery.

PS: Just the Value property of Li, neither of them will have the above problem. So either change the label or change the property.

The Value property of the Li tag in HTML is compatible with the problem

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.