Is this the right way to setup up an image within a link?

Posted by fire on Stack Overflow See other posts from Stack Overflow or by fire
Published on 2010-06-02T09:52:28Z Indexed on 2010/06/02 10:03 UTC
Read the original article Hit count: 160

Filed under:
|
    $('<a />').attr({
        'href': '#'
    })
    .append(
        $('<img />').attr({
            'id'    : 'img',
            'src'   : 'edit.png'
    }))
    .appendTo('body');

Is the the "right way" to go about adding <a href="#"><img src="edit.png" id="img" /></a> to the body?

Also how would I add some css onto the img?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery