Search code examples
jqueryjquery-load

jquery load element attribute href


I have the following

$('.quickview-dialog-left').load('/productlargetest .productlargeimage a');

the href of this a tag is an image. And I want to use that url and add an image inside the quickview-dialog-left but the above only brings in the entire a tag.

How would I bring in the href of the a tag?


Solution

  • $('.quickview-dialog-left').load('/productlargetest .productlargeimage a');
    $('.quickview-dialog-left').html("<img src='"+$('.quickview-dialog-left a').attr("href")+"'/>");
    

    Side comment: loading a whole page seems like an overkill to just get an image...