ngplayground
ngplayground

Reputation: 21647

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?

Upvotes: 0

Views: 741

Answers (1)

Christophe
Christophe

Reputation: 28154

$('.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...

Upvotes: 1

Related Questions