I found this answer, which is great. But what If I also have to wrap another element around that element? This is how I'm doing it now:
$('#screenshots').append($('<a href="' + link + '" title="' + title + '"><img src="' + el + '" alt="" width="200px" height="200px"></a>'));
Is there a better method of doing it this way?
If you are really interested in pure speed, it's going to be hard to beat pure DOM methods:
var div = document.getElementById("screenshots"), anchor, img;
if (div) {
anchor = document.createElement("A");;
anchor.href = link;
anchor.title = title;
img = document.createElement("IMG");
img.src = el;
img.alt = "";
img.width = 200;
img.height = 200;
anchor.appendChild(img);
div.appendChild(anchor);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With