Search code examples
javascriptjqueryinsertafter

append img after html text


Im trying to append an img right after a piece of text. Im using 'embedly' to load news items, so I have to perform on window load. Its really simple: JsFiddle

I cant figure out why its not working. I have tried many combinations and events(after,Insert etc) nothing seems to work.


Solution

  • You should use .after method.

    $('.embed').find('.description').after('<img src="http://latitudes.nu/wp-content/themes/theme-framework/framework/media/images/comment_icon.gif" style="width:14px; height:14px; border:none;" />');
    

    A fix to your demo.

    But, use setTimeout is not a good idea, you should set the callback option as the plugin provide.