Traversing the <title> element and accessing the content.
|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Traversing the <title> element and accessing the content.Hi, There seems to be a problem with using $('title').text() in IE7 and IE8 - wondering if this is a known problem and if there are any work arounds. sample code: <html> <head> <title>Example</title> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#test').val($('title').text()); }); </script> </head> <body> <input type="text" id="test" /> </body> </html> It works fine within Chrome and Firefox. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@... To unsubscribe from this group, send email to jquery-dev+unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Traversing the <title> element and accessing the content.Hi there,
The <title> tag acts a little differently from other DOM nodes. You can just edit the DOM property document.title directly. $(document).ready(function() { var titleText = document.title; $('#test').val(titleText); }); --Karl ____________ Karl Swedberg On Sep 11, 2009, at 7:01 AM, Ezence wrote:
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@... To unsubscribe from this group, send email to jquery-dev+unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Traversing the <title> element and accessing the content.Thanks, Karl.
I didnt know that the title element was treated as a special case and was selecting it using jQuery's $('title') selector syntax. That failed miserably in IE7. Changing my code to use document.title as you suggested solved the problem. On Sep 11, 9:08 am, Karl Swedberg <k...@...> wrote: > Hi there, > > The <title> tag acts a little differently from other DOM nodes. You > can just edit the DOM property document.title directly. > > $(document).ready(function() { > var titleText = document.title; > $('#test').val(titleText); > > }); > > --Karl > > ____________ > Karl Swedbergwww.englishrules.comwww.learningjquery.com > > On Sep 11, 2009, at 7:01 AM, Ezence wrote: > > > > > Hi, > > > There seems to be a problem with using $('title').text() in IE7 and > > IE8 - wondering if this is a known problem and if there are any work > > arounds. > > > sample code: > > > <html> > > <head> > > <title>Example</title> > > <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> > > > <script type="text/javascript"> > > $(document).ready(function(){ > > > $('#test').val($('title').text()); > > > }); > > </script> > > > </head> > > <body> > > <input type="text" id="test" /> > > </body> > > </html> > > > It works fine within Chrome and Firefox. -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@.... To unsubscribe from this group, send email to jquery-dev+unsubscribe@.... For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en. |
| Free embeddable forum powered by Nabble | Forum Help |