Bug Tracker

Modify

Ticket #4495 (closed bug: invalid)

Opened 4 years ago

Last modified 15 months ago

$('#inputElement').text() returns empty string in IE6

Reported by: tw2080 Owned by:
Priority: major Milestone: 1.3.2
Component: unfiled Version: 1.3.2
Keywords: IE6, text() empty string Cc:
Blocking: Blocked by:

Description

When I try to get the text value of a single input element in IE6, $('#inputElement').text(), an empty string is returned. In the same time document.getElementById('inputElement').value returns the correct value.

Change History

comment:1 Changed 4 years ago by tw2080

A small change in the code at line 208 fixes this problemm:

(208) text: function( text ) {

var ret = "";

jQuery.each( text
this, function(){

if( this.childNodes.length > 0 ) {

jQuery.each( this.childNodes, function(){

if ( this.nodeType != 8 )

ret += this.nodeType != 1 ?

( this.value
this.nodeValue ):

jQuery.fn.text( [ this ] );

});

} else if ( this.nodeType != 8 )

ret += this.nodeType == 1 ?

( this.value
this.nodeValue ):;

});

return ret;

},

comment:3 Changed 4 years ago by dmethvin

If you want the value of an input element, use .val() and not .text()

comment:4 Changed 4 years ago by dmethvin

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

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.