Reputation: 307
var loc=window.location.href,width="500px",height="450px";
var a=document.createElement("div");
a.id="xyz";
a.style.position="fixed";
a.style.width="500px";
a.style.height="450px";
a.style.top="0px";
a.style.right="0px";
$('body').appendChild(a);
a.innerHTML='<iframe id="submit" width="500px" height="450px" src="http://abc.html"><iframe>';
this code gives the error Result of expression '$('body').appendChild' [undefined] is not a function.
please help me as i cant figure out why this error is creeping in
Upvotes: 3
Views: 3197
Reputation: 8416
$('body') returns a jQuery object, not a DOM node. This object does not have an appendChild function. The jQuery equivalent is:
$('body').append(a);
Or, use get
to get the DOM node:
$('body').get(0).appendChild(a);
Upvotes: 5