Bug Tracker

Modify

Ticket #5163 (closed enhancement: fixed)

Opened 4 years ago

Last modified 15 months ago

$("#id").val(null) sets string "null" as value in IE

Reported by: maltalef Owned by: dmethvin
Priority: minor Milestone: 1.4.3
Component: attributes Version: 1.4.2
Keywords: val null string ie Cc:
Blocking: Blocked by:

Description

this is actually a bug in IE (tested in IE8 with compatibility mode on) that should be covered by jQuery. document.getElementById("someTextInput").value = null incorrectly assigns a string "null" as opposed to what happens in non-substandard browsers (ie an empty string is assigned). This behavior should be standardized when calling $("#someTextInput").val(null)

Change History

comment:1 Changed 4 years ago by shangxiao

Yep I've come across the same issue. It'd be nice if jQuery could cover this quirk ;) Thx!

comment:2 Changed 4 years ago by shangxiao

Test script:

<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function() {
    $('#test').val(null);
    alert($('#test').val() === "null");
});
</script>
</head>
<body>
<input type="hidden" id="test" value="" />
</body>
</html>

comment:3 Changed 3 years ago by dmethvin

  • Component changed from unfiled to attributes

comment:4 Changed 3 years ago by dmethvin

  • need changed from Review to Commit
  • Owner set to dmethvin

comment:5 Changed 3 years ago by john

  • Status changed from new to closed
  • Version changed from 1.3.2 to 1.4.2
  • Resolution set to fixed
  • Milestone changed from 1.4 to 1.4.3

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.