Shaun Hogg
Shaun Hogg

Reputation: 177

Javascript and Lightbox

I want to add Lightbox to a image which is output by Javascript. The image link is built up dynamically so thats why I am doing it this way!

I have looked on S.O. but no luck with what is already there...

The code currently is;

$("#imgMain img").attr("src","/_images/multi/"+productCode+"/"+imgCodeAlt+"_l.jpg"); 

And i somehow need to append it with rel="lightbox"

Thanks in advance :)

Shaun

Upvotes: 1

Views: 267

Answers (2)

Dipak
Dipak

Reputation: 12190

Try using -

$("#imgMain img").attr({
  src: '/_images/multi/"+productCode+"/"+imgCodeAlt+"_l.jpg',
  rel: 'lightbox'
});

Upvotes: 1

Mateusz Rogulski
Mateusz Rogulski

Reputation: 7445

Try :

JQuery

$("#imgMain img").attr("rel","lightbox");

Upvotes: 1

Related Questions