I ran into Don't load hidden images … and wanted to run the function reveal.
$(function () {
$("img").not(":visible").each(function () {
$(this).data("src", this.src);
this.src = "";
});
var reveal = function (selector) {
console.log("Viser billeder");
var img = $(selector);
img[0].src = img.data("src");
}
});
But how?
If I do this:
reveal();
It returns this in the console:
reveal is not defined
How should I call this?
Define reveal in the global scope like this, it should work fine.