Ticket #4548 (closed bug: duplicate)
jquery.text bug
| Reported by: | jidixuelang | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | manipulation | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
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;
},
So i think this problem maybe has the better one resolvent!
Change History
comment:2 Changed 3 years ago by dmethvin
- Status changed from new to closed
- Resolution set to worksforme
The cross-browser way to get a document's title is the document.title property.
comment:3 Changed 2 years ago by jitter
- Status changed from closed to reopened
- Component changed from unfiled to manipulation
- Priority changed from major to low
- Milestone 1.3.2 deleted
- Keywords jquery.text removed
- Resolution worksforme deleted
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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 /
--code end--
So i think this problem maybe has the better one resolvent!