Using jquery append() in <head> (in a function/class)

Posted by Anonymous on Stack Overflow See other posts from Stack Overflow or by Anonymous
Published on 2010-04-29T11:30:31Z Indexed on 2010/04/29 11:57 UTC
Read the original article Hit count: 407

Filed under:
|
|
|
|

I want to use the append() function from inside the <head>, in a function to be specific, like so:

function custom_img(src_img)
{
 $("div").append("<img src='"+src_img+"'>");
}
var myimg = new custom_img("test.jpg");

This is a quick example that I just wrote out. I want my function to make a new image like that every time I create a new object like this. Obviously this doesn't work, since the append() requires to be in the body (I've tried this).

How would I do this?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery