Reputation: 1
I want to make a site where there are some images, when I click on an image I want it to be the background image of the site, any suggestion?
Upvotes: 0
Views: 1001
Reputation: 263
if you know how to use JQuery, this should be easy:
$('#divTagId').click(function()
{
$("html").css("background-image", "url(/myimage.jpg)");
});
Upvotes: 0
Reputation: 4955
This can be done easily as per below:
jQuery:
$(function(){
$("#imageId").click(function() {
var myImage = $("img", this).attr("src");
$("body").css("background", "url('" + myImage + "')");
});
});
Upvotes: 0
Reputation: 324610
Something along the lines of:
<img src="myimage.jpg" onClick="document.body.style.backgroundImage = 'url('+this.src+')';;" />
Upvotes: 3