Bug Tracker

Modify

Ticket #5714 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

append() Doesn't Work for <head> Elements in IE

Reported by: gyrm Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: append, <head> Cc:
Blocking: Blocked by:

Description

The following code demonstrates:

var head = $('head');

head.append('<title>Yeah!</title>');

alert(head.html()); "Yeah!" added in FF3.5, Chrome3; not in IE8

var title = document.createElement('title');

title.appendChild(document.createTextNode('Buddy!'));

head[0].appendChild(title);

alert(head.html()); "Buddy!" added in all

Change History

comment:1 Changed 3 years ago by gyrm

Looks like this may be an issue with the <title> element specifically, which is strange.

var script = $('<script src="foo.js" />');
var title = $('<title>Buddy!</title>');
var link = $('<link rel="stylesheet" href="foo" />');

alert(script[0]);
alert(title[0]);   // "undefined" only in IE
alert(link[0]);

comment:2 Changed 3 years ago by dmethvin

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

"The HTML string cannot contain elements that are invalid within a div, such as html, head, body, or title elements."

 http://docs.jquery.com/Core/jQuery#htmlownerDocument

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.