I am trying to change the src
of an element by using the attr
property in mouseover
and then mouseleave
.
The idea is to change a banner while the mouse is under an element and refresh again after you exit.
I tried two ways:
1st
$('.quartaImagem').mouseover(function () {
$(".banner").attr("src", "Content/img/fotosHome/treinamentos.jpg");
});
$('.quartaImagem').mouseleave(function () {
bannerDefault;
});
2nd
$(document).ready(function (e) {
$('.quartaImagem').hover(function (e) {
$(".banner").attr("src", "Content/img/fotosHome/treinamentos.jpg");
}, function (e) {
$(this).attr('src', bannerDefault);
})
});