Bug Tracker

Modify

Ticket #4160 (closed bug: invalid)

Opened 4 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:

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

comment:1 follow-up: ↓ 2 Changed 4 years ago by 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".

comment:2 in reply to: ↑ 1 Changed 4 years ago by ghostdx

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 4 years ago by dmethvin

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 4 years ago by dz

Try:

<script>
$(function(){alert($('<li value="test"></li>').attr('value'));});
</script>

comment:5 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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);

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.