首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

live()的有关问题

2012-06-20 
live()的问题$(.cssraindemo3 tbody tr:even).addClass(odd)$(.cssraindemo3 tbody tr).hover(func

live()的问题
$('.cssraindemo3 tbody tr:even').addClass('odd');
  $('.cssraindemo3 tbody tr').hover(
  function () { $(this).addClass('highlight'); },
  function () { $(this).removeClass('highlight'); }
 );

请教下.因为我是动态生成表格的tr和td.所以以上两个语句都无效.请问是否可以live()生成以上语句?

[解决办法]

JScript code
$(".cssraindemo3 tbody tr").live('hover',    function() {        $(this).addClass('highlight');    },    function() {        $(this).removeClass('highlight');    });
[解决办法]
探讨

用原来的方法
$('.cssraindemo3 tbody tr').hover(
function () { $(this).addClass('highlight'); },
function () { $(this).removeClass('highlight'); }
);
鼠标离开后.tr能还原原来的样式.但用了LIVE()之后.好象只执行第一个function,……

热点排行