Yes, using DOM scripting:
$("#screenshots")
.append(
$("<a>")
.attr({
'href': link,
'title': title
})
.append(
$("<img>")
.attr({
'src': el,
'alt': '',
'width': '200px',
'height': '200px'
})
)
);
Demo.
This is quite a mouthful, but it's so simple that you'll be hitting yourself on the head when you find out just how easy it is.
What we do is select #screenshots
. We use append()
, and in the function we create an a
element, set its attributes using attr()
, and then proceed to use append()
again. In this nested append()
, we create an image and set its attributes.
So, we're creating an a
element, appending it to #screenshots
, creating an img
element, and appending that to the previously created a
element.
Please note the lack of semicolon inside the append()
function. It is essential that the jQuery declarations do not have the trailing semicolon or else the entire thing will not work.