JQuery给table动态增加样式
来源:互联网 发布:java bytebuffer c 编辑:程序博客网 时间:2024/05/16 16:08
本例子操作的table表的class为stripe
//将dom对象转换成jquery对象
$(document).ready(
function() {
//如果鼠标移到class为stripe的表格的tr上时,执行函数
$(".stripe tr").mouseover(function() {
$(this).addClass("over");
});
//给这行添加class值为over,并且当鼠标一出该行时执行函数
$(".stripe tr").mouseout(function() {
$(this).removeClass("over");
});
//点击变色,注意:因为有隔行变色,所以这里必须在触发toggleClass时,remove("alt").
//$(".stripe tr").click(function() { //移除该行的class
// $(this).toggleClass("click");
// $(this).removeClass("alt");
//});
//给class为stripe的表格的所有行添加class值为alt
$(".stripe tr").addClass("alt");
//给class为stripe的表格的偶数行添加class值为odd
//$(".stripe tr:even").addClass("odd");
//给class为stripe的表格的奇数行添加class值为alt
//$(".stripe tr:odd").addClass("alt");
//给class为stripe的表格的最后一行添加class值为last
$(".stripe tr:last").addClass("last");
//隐藏奇数tr,点击偶数tr使其下一个tr隐藏或者显示
//$('.stripe').find('tr:odd').hide().end().find('tr:even').click(
// function() {
// var answer = $(this).next();
// if (answer.is(':visible')) {
// answer.slideUp();
// } else {
// answer.slideDown();
// }
// });
//选择了所有的tr元素,然后去除了包含有th子元素的tr元素,加上点击事件
$('.stripe').find('tr').not(":has(th)").click(function(){alert("I was clicked!");});
//隐藏table第一tr和最后tr之外的所有tr
//$('.stripe').find('tr').not(":first").not(":last").hide();
//1.点击第一tr隐藏或显示其它tr
//$('.stripe').find('tr:first').click(function() {
//.next(),.nextAll,.prev(),.prevAll(),.parent(),.andself()
// $(this).nextAll().not(":last").each(function() {
// if ($(this).is(':visible')) {
// $(this).slideUp();
// } else {
// $(this).slideDown();
// }
// });
//});
//2.点击第一tr隐藏或显示其它tr
//$('.stripe').find('tr:first').toggle(function() {
// $('.stripe').find('tr').not(":first").not(":last").hide('slow');
//}, function() {
// $('.stripe').find('tr').not(":first").not(":last").show('fast');
//});
//3.点击第一tr隐藏或显示其它tr
$('.stripe').find('tr:first').toggle(function() {
$('.stripe').find('tr').not(":first").not(":last").animate({
height: 'hide',
opacity: 'hide'
}, 'slow');
}, function() {
$('.stripe').find('tr').not(":first").not(":last").animate({
height: 'show',
opacity: 'show'
}, 'slow');
});
});
- JQuery给table动态增加样式
- jquery方法给table动态增加行
- JQUERY方法给TABLE动态增加 删除行
- jquery之table:给table动态增加行、清空table
- jquery 动态给table赋值
- jquery给动态增加元素绑定事件
- jquery给table动态添加tr
- 如何给一个ContentPage动态增加Css 样式单
- 如何给一个ContentPage动态增加Css 样式单
- jquery在html中动态增加数据到table中
- 动态增加元素时初始化jquery样式实例
- jquery动态给指定的table添加一行tr td
- JS给Table增加行
- table表格动态增加行/删除行,动态给highchart赋值
- 用jquery给元素动态绑定事件及样式
- 给超级链接增加其他样式
- Table动态增加删除行
- Table动态增加删除行
- POJ分类
- ecshop二次开发:ecshop库表结构完整版(一)
- Ubuntu 下安装 Code::Blocks
- 怀化气象论坛邀请码
- 闲谈
- JQuery给table动态增加样式
- vb-跨域访问,获得特定的frame进行处理
- delphi cxgrid 使用方法
- 不显示删除回复显示所有回复显示星级回复显示得分回复 发一个自己做的修改植物大战僵尸阳光的小程序
- Registering JavaScript object methods as callbacks(注册一个对像方法为回调函数[解决回调函数的上下文问题])
- hibernate中lazy的使用
- OGRE中资源文件的缩减
- android 2.3 SDK
- .h头文件 .lib库文件 .dll动态链接库文件关系