jQuery get attribute

Posted by Happy on Stack Overflow See other posts from Stack Overflow or by Happy
Published on 2010-06-16T12:40:06Z Indexed on 2010/06/16 15:02 UTC
Read the original article Hit count: 104

Filed under:
|

There are many class="item" blocks on the page.

For each one there is different var item_link and ajax request.

Ajax searches for src attribute of .message img and throws it to var src.

$(".item").each(function(){
    var item_link = "http://...";
    $(this).prepend('<div class="src"></div>');
    $.get(item_link, function(data) {
        var src = $('.message img', data).attr('src');
    });
});

How to print var src to <div class="src"></div>?

Thanks.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX