sou*_*rgy 24 jquery addclass hover removeclass jquery-hover
想要改变盒子上的边框颜色..
..当用户将鼠标移出/移出时..
这是尝试过的代码..需要工作!
JQuery的:
<script>
$("result").hover(
function () {
$(this).addClass("result_hover");
},
function () {
$(this).removeClass("result_hover");
}
);
</script>
Run Code Online (Sandbox Code Playgroud)
CSS3:
<style>
.result {
height: 72px;
width: 100%;
border: 1px solid #000;
}
.result_hover {
border: 1px solid #fff;
}
</style>
Run Code Online (Sandbox Code Playgroud)
HTML5:
<div class="result">
<div class="item">
<div id="item1">
<i class="icon"></i> ##
</div>
</div>
<div>
Run Code Online (Sandbox Code Playgroud)
谢谢你的期待
Adi*_*dil 60
你忘了了结果类dot的类选择器.
$(".result").hover(
function () {
$(this).addClass("result_hover");
},
function () {
$(this).removeClass("result_hover");
}
);
Run Code Online (Sandbox Code Playgroud)
您可以在悬停事件中使用toggleClass
$(".result").hover(function () {
$(this).toggleClass("result_hover");
});
Run Code Online (Sandbox Code Playgroud)
A. *_*lff 11
你可以使用:{in and out function callback}
$(".result").hover(function () {
$(this).toggleClass("result_hover");
});
Run Code Online (Sandbox Code Playgroud)
对于您的示例,最好使用CSS伪类:hover:{no js/jquery needed}
.result {
height: 72px;
width: 100%;
border: 1px solid #000;
}
.result:hover {
background-color: #000;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
122751 次 |
| 最近记录: |