【发布时间】:2011-04-12 21:29:37
【问题描述】:
当我将其悬停时,我试图为图像添加边框,但它没有添加它: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');
});
【问题讨论】:
-
你为什么用jQuery而不是css?
.thumb:hover { border: 1px solid #000 }? -
你有 jsfiddler.net 的例子吗?
标签: jquery css image class add