Bug Tracker

Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#4548 closed bug (duplicate)

jquery.text bug

Reported by: jidixuelang Owned by:
Priority: low Milestone:
Component: manipulation Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:

Description

[code] alert($('title').text()); code

As using 'jquery.text' to fetch the text of document.title,I will get nothing with IE! But work fine,when i use firefox or chrome!

I see,IE has a question at the realization of title-node. Executeing the following code with IE,i will get zero.However,the 'one' is expected and truly at the other browser! [code] document.getElementsByTagName('title')[0].childNodes.length code

Also , I find modifing the source code of jquery can avoid this question,Only with which part about 'jquery.text'. [code]

/ @id jQuery.text /

text: function( text ) {

if ( typeof text != "object" && text != null )

return this.empty().append( (this[0] && this[0].ownerDocument
document).createTextNode( text ) );

var ret = "";

jQuery.each( text
this, function(){

ret += this.innerText!=undefined?

this.innerText:this.textContent!=undefined?

this.textContent:;

});

return ret;

},

code

So i think this problem maybe has the better one resolvent!

Change History (5)

comment:1 Changed 11 years ago by jidixuelang

As the format is bad, I rewrite the above content!

--code start--

alert($('title').text());

--code end--

As using 'jquery.text' to fetch the text of document.title,I will get nothing with IE! But work fine,when i use firefox or chrome!

I see,IE has a question at the realization of title-node. Executeing the following code with IE,i will get zero.However,the 'one' is expected and truly at the other browser! --code start--

document.getElementsByTagName('title')[0].childNodes.length

--code end--

Also , I find modifing the source code of jquery can avoid this question,Only with which part about 'jquery.text'.

--code start--

/ @id jQuery.text /

text: function( text ) {

if ( typeof text != "object" && text != null )

return this.empty().append( (this[0] && this[0].ownerDocument
document).createTextNode( text ) );

var ret = "";

jQuery.each( text
this, function(){

ret += this.innerText!=undefined?

this.innerText:this.textContent!=undefined?

this.textContent:;

});

return ret;

},

--code end--

So i think this problem maybe has the better one resolvent!

comment:2 Changed 9 years ago by dmethvin

Resolution: worksforme
Status: newclosed

The cross-browser way to get a document's title is the document.title property.

comment:3 Changed 9 years ago by jitter

Component: unfiledmanipulation
Keywords: jquery.text removed
Milestone: 1.3.2
Priority: majorlow
Resolution: worksforme
Status: closedreopened

comment:4 Changed 9 years ago by jitter

Resolution: duplicate
Status: reopenedclosed

comment:5 Changed 9 years ago by jitter

Duplicate of #2755.

Note: See TracTickets for help on using tickets.