脚本宝典收集整理的这篇文章主要介绍了js实例教程-jquery开发之 $().hover(func1, funct2)使用方法,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。
因为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>
}
});
. 代码如下:
<body>
<p class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<p class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><p class="left">{lang user/repick}</p></a>
<a href="#"><p class="right">{lang user/reply}</p></a>
</p>
</p>
<p class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<p class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><p class="left">{lang user/repick}</p></a>
<a href="#"><p class="right">{lang user/reply}</p></a>
</p>
</p>
<p class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<p class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff; BACKGROUND-COLOR: #ffffff">display:none</SPAN>">
<a href="#"><p class="left">{lang user/repick}</p></a>
<a href="#"><p class="right">{lang user/reply}</p></a>
</p>
</p>
<p class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<p class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><p class="left">{lang user/repick}</p></a>
<a href="#"><p class="right">{lang user/reply}</p></a>
</p>
</p>
<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>
因为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>
}
});
. 代码如下:
<body>
<p class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<p class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><p class="left">{lang user/repick}</p></a>
<a href="#"><p class="right">{lang user/reply}</p></a>
</p>
</p>
<p class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<p class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><p class="left">{lang user/repick}</p></a>
<a href="#"><p class="right">{lang user/reply}</p></a>
</p>
</p>
<p class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<p class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff; BACKGROUND-COLOR: #ffffff">display:none</SPAN>">
<a href="#"><p class="left">{lang user/repick}</p></a>
<a href="#"><p class="right">{lang user/reply}</p></a>
</p>
</p>
<p class="<SPAN style="COLOR: #0000ff">water</SPAN>">
<p class="<SPAN style="COLOR: #0000ff">action</SPAN>" style="<SPAN style="COLOR: #3366ff">display:none</SPAN>">
<a href="#"><p class="left">{lang user/repick}</p></a>
<a href="#"><p class="right">{lang user/reply}</p></a>
</p>
</p>
<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>
觉得可用,就经常来吧!Javascript技巧 脚本宝典 欢迎评论哦! js技巧,巧夺天工,精雕玉琢。小宝典献丑了!
以上是脚本宝典为你收集整理的js实例教程-jquery开发之 $().hover(func1, funct2)使用方法全部内容,希望文章能够帮你解决js实例教程-jquery开发之 $().hover(func1, funct2)使用方法所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。