Reputation: 27
I'm using slidy.js to cycle through several images inside a div.
My question is: How can I use jQuery to wrap <a href="http://www.google.com">
and </a>
around each image in the div (whose id is "imgFade")?
Thanks in advance!
Adam
Upvotes: 0
Views: 2140
Reputation: 1151
jQuery docs (http://api.jquery.com/wrap/) seem to recommend including the closing tag, which all the other answers have self-closed. ie:
$("#imgFade img").wrap("<a href='http://www.google.com'></a>");
Upvotes: 0
Reputation: 79021
Yes you can use the .wrap()
Example:
$("#yourdiv img").wrap('<a href="http://www.google.com" />');
// Note: the self closing pattern ^ THIS is how you should define the wrapping element
This is wrap a link around all the images inside the div with id="yourdiv"
Upvotes: 3
Reputation: 9037
You can use jQuery's .wrap() method:
$('div#imgFade img').wrap('<a href="http://www.google.com" />');
Upvotes: 1