Rambling about JS
Remember, you can attach actions to events by assigning an anonymous function to said event.
Before this, yes, I know, this is basic, but I’ve a post coming on the subject on my way of learning things. :D
Example: Let’s open up an image from a link, and preload the image before displaying it and using jQuery to display, because I’m lazy with vanilla JS;
var preload-image = new Image();
preload-image.onload = function() {
var image = $("#image");
image.attr("src", "goatse.jpg").show();
}
preload-image.src = "goatse.jpg";
We could probably add a delete statement to remove the unwanted and then unused image tag;
EDIT: Thanks for Antti S. for reminding me that you can’t delete variables declared with var, so instead just null it;
preload-image = null;
-
fuckyeahgoatse reblogged this from piparkaq
-
piparkaq posted this