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