Bug Tracker

Modify

Ticket #6835 (closed bug: wontfix)

Opened 3 years ago

Last modified 3 years ago

.val() returns text on button elements with <= IE7

Reported by: septemberbrain Owned by:
Priority: undecided Milestone: 1.4.2
Component: attributes Version: 1.4.2
Keywords: value of button with different browsers Cc:
Blocking: Blocked by:

Description (last modified by dmethvin) (diff)

<script type="text/javascript"> $(document).ready(function(){

$('button').each(function(){

alert ($(this).attr('value')); alert ($(this).val());

})

});

</script>

<button id="AUT" value="AUT">Automotive</button> <button id="CON" value="CON">Consumer</button> <button id="ENT" value="ENT">Enabling Technologies</button> <button id="IND" value="IND">Industrial</button> <button id="NET" value="NET">Networking</button>

This script gives different values depending on whether you are using IE or another browser. Not sure if this is a bug or not but I thought someone should know.

David

Attachments

test-6835.html Download (695 bytes) - added by dmethvin 3 years ago.
Test case

Change History

Changed 3 years ago by dmethvin

Test case

comment:1 Changed 3 years ago by dmethvin

  • Description modified (diff)

I've attached a test case that works properly with IE8 and shows the difference between .value, .val(), and .attr("value"); I don't have IE6/7 handy right now but if someone can run the test case and attach output it might help.

comment:2 Changed 3 years ago by dmethvin

OK, I got to an IE6 system and the test case indeed returns the innerText for *all* cases there. I also changed it to check this.getAttribute("value") and that is wrong as well. So I don't even see a way for jQuery to get the actual value property/attribute. See the community discussion here (near the bottom of the page):

 http://msdn.microsoft.com/en-us/library/ms535211%28VS.85%29.aspx

I'll leave the ticket open for now, but this looks like it will be a wontfix unless someone has a good solution.

comment:3 Changed 3 years ago by addyosmani

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to wontfix

As a more suitable solution (aside from improved documentation on the original issue) has not been proposed in the months since the original ticket was submitted, I agree with the original call by dmethvin to set this ticket to wontfix for now.

Please feel free to re-open if a working solution is found.

comment:4 Changed 3 years ago by jitter

It seems I found a way to get at the really value of the value attribute (at least in IE6 can't test other IE versions at the moment).

By using the DOM Level 1 getAttributeNode function.

this.getAttributeNode("value").value

 live test case

Hope this still gets noted as I can't reopen the ticket

Last edited 3 years ago by jitter (previous) (diff)

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.