Opened 14 years ago
Closed 14 years ago
#4160 closed bug (invalid)
Value Attribute (as meta-data) Only works with numbers
Reported by: | ghostdx | Owned by: | |
---|---|---|---|
Priority: | trivial | Milestone: | 1.3.2 |
Component: | unfiled | Version: | 1.3.1 |
Keywords: | value attribute | Cc: | |
Blocked by: | Blocking: |
Description
I tried changing SELECT > OPTION into UL > LI and adding the value attribute of the options to the LI. It worked fine with numbers but when I tried to use strings it would return a -1. I changed the attribute name to "valuez" and it worked fine.
Change History (5)
comment:1 follow-up: 2 Changed 14 years ago by
comment:2 Changed 14 years ago by
Replying to dz:
Here's a sample test case:
http://jquery.nodnod.net/cases/121
The "valuez" attribute shows the correct value whilst the "value" attribute on the li is "0".
Thanks for the example! :) I think it does not work not only with UL > LI but with any HTML tag with the VALUE attribute.
comment:3 Changed 14 years ago by
Sorry, I am not seeing the issue. It looks like the test case was edited. can you include a few short lines that demonstrate the problem? To put code in the post, use three { characters in a row with no spaces:
{{{ your code here }}}
comment:4 Changed 14 years ago by
Try:
<script> $(function(){alert($('<li value="test"></li>').attr('value'));}); </script>
comment:5 Changed 14 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
In HTML4 the value attribute of an li gives you the ordered list number:
http://www.w3schools.com/tags/att_li_value.asp
So the cause lies outside jQuery, you can see it from this example:
<li id="arf" value="dog"></li> alert(document.getElementById("arf").value);
Here's a sample test case:
http://jquery.nodnod.net/cases/121
The "valuez" attribute shows the correct value whilst the "value" attribute on the li is "0".