当我悬停它时,我试图为图像制作边框,但它没有添加它:S,但我尝试了 console.log,它显示了我写的文本,但它没有向它添加类:S
这是我的代码
<style>
.test {
border: 1px solid #000;
}
</style>
// add a class to the image that is focus on
$('#small-image .thumb').hover(function() {
$(this).addClass('test');
console.log('hover');
}, function() {
$(this).removeClass('test');
console.log('out');
});
最佳答案
为什么需要 javascript?
标记:
<div id="foo"></div>
CSS:
#foo {width:50px; height:50px; border: 1px solid blue}
#foo:hover {border-color: red}
关于jquery添加类问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5641857/