You dont need to specify the context when creating new elements, and appendTo takes 1 argument, try like this:
$('<div>text</div>').appendTo(window.document); untested, but that should work On 8/12/07, Jay W <[EMAIL PROTECTED]> wrote: > > > Thanks. I tried it using $('<div>new div text here</div>', > window.document).appendTo('body'), nothing happened; If I try $ > ('<div>new div text here</div>', window.document).appendTo('body', > window.document), an "Invalid Argument" error is thrown. > > Any suggestion? > > Thanks > > On Aug 12, 11:43 am, "Matt Stith" <[EMAIL PROTECTED]> wrote: > > You need to add the element to the document via .appendTo, .prependTo, > or > > one of those similar methods. It isnt added to the DOM just by creating > it. > > > > On 8/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > > > > > I can use $('#id', window.document) to get an existing element from a > > > document in a frame. > > > However, I also try to use $(html) to create a new DIV in any frame > > > through function on top window and used the format "$('<div>new div > > > text here</div>', window.document)", but it doesn't work. Is it > > > possible to do this? > > > > > Thanks. > > > > > <html> > > > <head> > > > <script src='jquery.js'></script> > > > <script src='jQuery.frameReady.js'></script> > > > > > </head> > > > <script> > > > > > top.addDiv = function (window) { > > > var doc = window.document; > > > var a = $('<div>test div</div>', doc); > > > alert(top.left.document.body.innerHTML); > > > $('#show', doc).toggle(); > > > } > > > > > </script> > > > <FRAMESET cols="20%, 80%"> > > > <FRAME name=left src="testleft.html"> > > > <FRAME name=right src="testright1.html"> > > > </FRAMESET> > > > </html> > >