Reputation:
Hi, I have a HTML image that is setup like this:
<input id="img" type="image" src="">
How can I change src
on hover?
.
Upvotes: 1
Views: 167
Reputation: 4431
use jQuery for this tag
<input id="img1" type="image" src="">
$("#img1").hover(function() {
$(this).addClass("blue");
}, function() {
$(this).removeClass("blue");
});
in css class you can write src for this input image tag.
Upvotes: 0
Reputation: 1375
Try this:
<script type="text/javascript">
$(document).ready(function(){
$("#img").hover(function(){
$(this).attr("src","img1.jpg");
},function(){
$(this).attr("src","img2.jpg");
});
});
</script>
<input id="img" type="image" src="">
Upvotes: 3
Reputation: 6000
Expecting an item to be hovered on i suggest this:
$('.item').mouseover(function (e) {
var id = $(this).val();
$("#img").attr("src",id);
});
Upvotes: 0