How to change Background Image of input button using Javascript
i want to change my button background image using javascript so i wrote a co开发者_开发百科de like this but seems to be it's not working well.
$('#search-button-input').css('background-image', $.format("url('Images/%(color)s.png')", { color: e }));
e is image comes with fire the some other function.
my input tag like this
<input id="search-button-input" type="button" name="q" class="search-button-input" value="search" />
Well, one way to do it is if you're using this function to respond to a mouseover event, an easier way to do it is with CSS itself. In CSS you can specify the style of something which is being hovered over like this:
element:hover { ... }
If this isn't what you want, then you can do something like this for example:
element.setAttribute("style", "color: blue; background-color: red");
精彩评论