Yep, that was all it took. Thanks!
On Jan 11, 3:43 pm, Karl Rudd karl.r...@gmail.com wrote:
Try closing the tag, ie:
$('#myDiv').append($('h2/h2'));
Actually the second $() shouldn't be needed:
$('#myDiv').append('h2/h2');
Karl Rudd
On Mon, Jan 12, 2009 at 7:35 AM, Joe White vulcanvik...@gmail.com wrote:
I'm troubleshooting a problem where my text wasn't showing up in IE.
I've narrowed the problem down to creating a DOM node dynamically
(with $(html)) and then passing it to append(). In FireFox, append
will add the node as expected; but when passed a dynamically-created
node in IE, it does nothing. No error message is displayed; it just
silently fails, and no node is added to the page.
Here's a trivial example:
$('#myDiv').append($('h2'));
I put that code into the ready event, on a page with a div id=myDiv.
I also added some CSS to put a border on the h2, so I'd be able to see
whether it got added. Result: in FireFox, I can see the border,
proving that the h2 got added. In IE, nothing. No error.
If, instead, I find an existing h2 using its selector (e.g. $
('#myH2')), and append() that (instead of a dynamically-created one),
then IE works fine; it moves that existing element into myDiv. It
appears to just be when a DOM element is dynamically created with $
(html), and then append()ed, that there's a problem.
Full example:
html
head
styleh2{border:1px solid blue;}/style
script src=../vendor/jquery/jquery-1.2.6.js/script
script
$(function(){
$('#myDiv').append($('h2'));
});
/script
/head
body
div id=myDiv/div
/body
/html
Expected behavior: when you run this, you should get a blank page with
a 2px-tall blue line extending across the page. (This is the border
around the h2.) FireFox shows this expected behavior.
Actual behavior (IE6 on Windows): you get a blank page. The status bar
just says Done like usual, and does not show that any errors
occurred.
Is this a bug in jQuery? Or am I misunderstanding how $(html) is meant
to be used?