I am Displaying all the images from database to image tag no ai have problem in after seleting one image that image should be apply as background. What is javascript for writting this? thank you....
Please use the "Add Comment" option for this kind of question - only use "Add Answer" if you actually have an answer - Thanks.
Sohnee
2010-03-12 09:22:11
A:
To set a background image using JavaScript, you could do this:
document.getElementById("myElement").style.backgroundImage = "myimage.png";
But if you are using asp.net MVC, you could set a snippet of CSS, or the style of the element in the view instead, which would remove the need to use JavaScript. For example...
<div style='background-image: url(<%= Model.MyImage %>);'>
Sohnee
2010-03-12 09:18:00