jquery 之 $().hover(func1, funct2)使用方法
时间:2022-11-12 10:12:51|栏目:jquery|点击: 次
因为hover不是标准的事件,因此无法直接使用live进行处理,故使用以下方法代替,效果一样。
$("<SPAN style="COLOR: #0000ff">table tr</SPAN>").live({
<SPAN style="BACKGROUND-COLOR: #99ccff">mouseenter:</SPAN>
function()
{
<SPAN style="COLOR: #008000">//todo</SPAN>
},
<SPAN style="BACKGROUND-COLOR: #99ccff">mouseleave:</SPAN>
function()
{
<SPAN style="COLOR: #008000">//todo</SPAN>
}
});
在循环输出的<div>中,只针对某个<div>下的内容进行处理的时:可以使用$(this).find()来实现:
<body>
<div class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<div class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><div class="left">{lang user/repick}</div></a>
<a href="#"><div class="right">{lang user/reply}</div></a>
</div>
</div>
<div class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<div class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><div class="left">{lang user/repick}</div></a>
<a href="#"><div class="right">{lang user/reply}</div></a>
</div>
</div>
<div class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<div class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff; BACKGROUND-COLOR: #ffffff">display:none</SPAN>">
<a href="#"><div class="left">{lang user/repick}</div></a>
<a href="#"><div class="right">{lang user/reply}</div></a>
</div>
</div>
<div class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<div class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><div class="left">{lang user/repick}</div></a>
<a href="#"><div class="right">{lang user/reply}</div></a>
</div>
</div>
<script type="text/javascript">
$("<SPAN style="COLOR: #0000ff">.water</SPAN>").<SPAN style="COLOR: #800080">hover</SPAN>(
function (){
$(this).<SPAN style="COLOR: #800080">find</SPAN>("<SPAN style="COLOR: #0000ff">.action</SPAN>").show();
},
function (){
$(this).<SPAN style="COLOR: #800080">find</SPAN>("<SPAN style="COLOR: #0000ff">.action</SPAN>").hide();
}
)
</script>
</body>
复制代码 代码如下:
$("<SPAN style="COLOR: #0000ff">table tr</SPAN>").live({
<SPAN style="BACKGROUND-COLOR: #99ccff">mouseenter:</SPAN>
function()
{
<SPAN style="COLOR: #008000">//todo</SPAN>
},
<SPAN style="BACKGROUND-COLOR: #99ccff">mouseleave:</SPAN>
function()
{
<SPAN style="COLOR: #008000">//todo</SPAN>
}
});
在循环输出的<div>中,只针对某个<div>下的内容进行处理的时:可以使用$(this).find()来实现:
复制代码 代码如下:
<body>
<div class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<div class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><div class="left">{lang user/repick}</div></a>
<a href="#"><div class="right">{lang user/reply}</div></a>
</div>
</div>
<div class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<div class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><div class="left">{lang user/repick}</div></a>
<a href="#"><div class="right">{lang user/reply}</div></a>
</div>
</div>
<div class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<div class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff; BACKGROUND-COLOR: #ffffff">display:none</SPAN>">
<a href="#"><div class="left">{lang user/repick}</div></a>
<a href="#"><div class="right">{lang user/reply}</div></a>
</div>
</div>
<div class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<div class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><div class="left">{lang user/repick}</div></a>
<a href="#"><div class="right">{lang user/reply}</div></a>
</div>
</div>
<script type="text/javascript">
$("<SPAN style="COLOR: #0000ff">.water</SPAN>").<SPAN style="COLOR: #800080">hover</SPAN>(
function (){
$(this).<SPAN style="COLOR: #800080">find</SPAN>("<SPAN style="COLOR: #0000ff">.action</SPAN>").show();
},
function (){
$(this).<SPAN style="COLOR: #800080">find</SPAN>("<SPAN style="COLOR: #0000ff">.action</SPAN>").hide();
}
)
</script>
</body>
上一篇:jQuery EasyUI API 中文文档 - Dialog对话框
栏 目:jquery
下一篇:没有了
本文标题:jquery 之 $().hover(func1, funct2)使用方法
本文地址:http://www.codeinn.net/misctech/218813.html