Leahcim
Leahcim

Reputation: 42069

valid JS but mouseover not working

i'm struggling with the lowly mouseover to change a background image. JSLint is telling me my code is valid but it's still not working. Can you help?

http://jsfiddle.net/kxNvW/23/

html

<div class="btn large contempt">


</div>

css

.btn.large.contempt {
    background: url(http://dummyimage.com/100x100/83c79f/fff);
    width: 100px;
    height: 100px;

}

jquery

$(document).ready(function() {
 $(".btn.large.contempt").bind('mouseover', function() {
$(".btn.large.contempt").attr('background','url(http://dummyimage.com/100x100/c78383/fff)');
 });
});

Upvotes: 0

Views: 63

Answers (2)

Amadan
Amadan

Reputation: 198526

Replace attr with css - background is a CSS property, not a HTML one.

Upvotes: 5

Cyclonecode
Cyclonecode

Reputation: 30131

Try this one: http://jsfiddle.net/kxNvW/29/

Upvotes: 2

Related Questions