jquery实现控制表格行高亮实例 - Web前端
作者:98wpeu发布时间:2026-06-21分类:网页前端技术浏览:103
[CSS]
复制代码 代码如下:
<style>
.height{
background:#666666; /*背景颜色为灰色*/
}
tr{
cursor: pointer; /*手形*/
}
</style>
<style>
.height{
background:#666666; /*背景颜色为灰色*/
}
tr{
Cursor: pointer; /*手形*/
}
</style>
[html]
复制代码 代码如下:
<body>
<tableborder="1" width="40%">
<tr><th></th><th align="left">姓名</th><th align="left">性别</th><th align="left">居住地</th></tr>
<tr>
<td><inputtype="radio" name="radio" /></td><td>张三</td><td>男</td><td>北京</td>
</tr>
<tr>
<td><input type="radio" name="radio" /></td><td>李四</td><td>男</td><td>上海</td>
</tr>
<tr>
<td><input type="radio" name="radio" /></td><td>王五</td><td>女</td><td>深圳</td>
</tr>
<tr>
<td><input type="radio" name="radio" /></td><td>赵六</td><td>女</td><td>北京</td>
</tr>
<tr>
<td><input type="radio" name="radio" /></td><td>孙七</td><td>男</td><td>上海</td>
</tr>
</table>
</body>
<body>
<TABle border="1" width="40%">
<tr><th></th><th align="left">姓名</th><th align="left">性别</th><th align="left">居住地</th></tr>
<tr>
<td><input type="radio" name="radio" /></td><td>张三</td><td>男</td><td>北京</td>
</tr>
<tr>
<td><input type="radio" name="radio" /></td><td>李四</td><td>男</td><td>上海</td>
</tr>
<tr>
<td><input type="radio" name="radio" /></td><td>王五</td><td>女</td><td>深圳</td>
</tr>
<tr>
<td><input type="radio" name="radio" /></td><td>赵六</td><td>女</td><td>北京</td>
</tr>
<tr>
<td><input type="radio" name="radio" /></td><td>孙七</td><td>男</td><td>上海</td>
</tr>
</table>
</body>
JQuery
[javascript]
复制代码 代码如下:
plAIncopyPRint?$(document).ready(function(){
//第一种写法: $("tr:gt(0)") 第一行标题不起作用
$("tr:gt(0)").click(function(){
$(this).addClass("height").siblings().removeclass("height").end().find(":radio").attr("checked",true);
})
//第二种写法:$("tr:not(:first)")
/*$("tr:not(:first)").click(function(){
$(this).addClass("height").siblings().removeClass("height").end().find(":radio").attr("checked",true);
})*/
})
$(document).ready(function(){
//第一种写法: $("tr:gt(0)") 第一行标题不起作用
$("tr:gt(0)").click(function(){
$(this).addClass("height").siblings().removeClass("height").end().find(":radio").attr("checked",true);
})
//第二种写法:$("tr:not(:first)")
/*$("tr:not(:first)").click(function(){
$(this).addClass("height").siblings().removeClass("height").end().find(":radio").attr("checked",true);
})*/
})
相关推荐
- jQuery+Ajax+PHP+Mysql实现分页显示数据实例讲解 - Web前端
- JQuery+Ajax实现数据查询、排序和分页功能 - Web前端
- jQuery实现带分组数据的Table表头排序实例分析 - Web前端
- jQuery实现单击弹出Div层窗口效果(可关闭可拖动) - Web前端
- 基于Jquery+div+css实现弹出登录窗口(代码超简单) - Web前端
- jQuery实现多级下拉菜单jDropMenu的方法 - Web前端
- jQuery表单验证功能实例 - Web前端
- jQuery 如何给Carousel插件添加新的功能 - Web前端
- jQuery实现点击小图片淡入淡出显示大图片特效 - Web前端
- jquery实现在网页指定区域显示自定义右键菜单效果 - Web前端
- 网页前端技术排行
-
- 1[Web前端]用javascript实现默认图片替代未显示的图片 - Web前端
- 2分析Iconfont-阿里巴巴矢量常用图标库 - Web前端
- 3jQuery实例教程:制作网页中可折叠的面板 - Web前端
- 4【第六章】Foundation之按钮和下拉功能 - Web前端
- 5基于jquery的滚动条滚动固定div(附演示下载) - Web前端
- 6jQuery编写widget的一些技巧分享 - Web前端
- 7分享精心挑选的12款优秀jQuery Ajax分页插件和教程 - Web前端
- 8jQuery实现鼠标移到元素上动态提示消息框效果 - Web前端
- 9在Mac/PC上远程调试iPhone/iPad上的网页 - Web前端
- 最近发表
-
- WordPress随机显示特色图片插件:Random Post Thumbnails
- KeePass实现Chrome浏览器自动填充密码方法一
- LNMP一键包nginx 301强制跳转到https教程
- KeePass实现Chrome浏览器自动填充密码方法二
- #建站# 免费的VPS管理软件Xshell8/Xftp8中文版下载
- 使用Xshell 8连接VPS教程_电脑登录vps的方法
- WordPress评论界面添加烟花????效果
- 不同浏览器书签同步方案:坚果云+Floccus_详细使用教程
- iOS端KeePassXC客户端APP:Strongbox Password Safe
- 给WordPress评论中的Gravatar头像图片添加ALT属性


