鼠标移动到图片上时,显示大图片

本文介绍了一种使用jQuery实现的表格美化方法,包括奇偶行变色、鼠标悬停时显示图片详情等功能,并实现了复选框的选择联动。

 

HTML标签中的一部分,仅供参考

<tr>
<td><input type="checkbox" class="checkbox1"/></td>
<td>1002</td>
<td>小猫咪</td>
<td><img src="img/02.jpg" height="100" width="100" alt=""/></td>               //图片
<td>200</td>
<td><input type="button" value="添加"/></td>
</tr>

 

<img id="imgTip" class="clsImg" src="img/04.jpg" alt="" />    //写在外面,隐藏显示,定位提示图片的位置

.clsImg{
position:absolute;
border:1px solid #ccc;
width:200px;
height:200px;
display:none;

}

JS部分实现功能:

<script type="text/javascript" src="../jquery-1.8.3.js"></script>
<script type="text/javascript">
$(function(){

 $("table tr:nth-child(odd)").css("background","#CCF");    //奇偶行变色

var x=5; var y=15;
$("table tr td img").mousemove(function(e) {
$("#imgTip").attr("src",this.src).css({"top":(e.pageY+y)+"px","left":(e.pageX+x)+"px"}).show(600);
});

$("table tr td img").mouseout(function() {
$("#imgTip").hide();
});

 

/*复选框单机事件*/

$("#checkAll").click(function() {
if(this.checked){
$("table tr td input[type=checkbox]").attr("checked",true);
}else
{
$("table tr td input[type=checkbox]").attr("checked",false);
}
});



});
</script>

转载于:https://www.cnblogs.com/eyunhua/p/3714150.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值