Skip to main content

Bug Tracker

Side navigation

#4548 closed bug (duplicate)

Opened April 16, 2009 04:38PM UTC

Closed February 18, 2011 01:42PM UTC

Last modified February 18, 2011 01:42PM UTC

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!

Attachments (0)
Change History (5)

Changed April 16, 2009 04:45PM UTC by jidixuelang comment:1

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!

Changed June 12, 2010 03:58AM UTC by dmethvin comment:2

resolution: → worksforme
status: newclosed

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

document.title
property.

Changed February 18, 2011 01:42PM UTC by jitter comment:3

component: unfiledmanipulation
keywords: jquery.text
milestone: 1.3.2
priority: majorlow
resolution: worksforme
status: closedreopened

Changed February 18, 2011 01:42PM UTC by jitter comment:4

resolution: → duplicate
status: reopenedclosed

Changed February 18, 2011 01:42PM UTC by jitter comment:5

Duplicate of #2755.