does anyone know how to put background image inside a textbox? i want to do is when i click the textbox it will change the background with an image.Does anyone know how to do th
To put a background image inside an input
element you need to set background-image
in CSS:
input {
background-image: url('image.png');
}
You can do it programmatically via JavaScript by adding/removing a class, or directly using this.style.backgroundImage
. So here's an example:
var i = document.getElementById('i');
i.addEventListener('click', function() {
i.style.backgroundImage = "url('image.png')";
});
Demo