> 'click .enable': function(e, value, row, index) {
> var that = $(this);
>
> // console.log(row);
> // console.log($(that).closest("tr").find(".stop"));
> $(that).closest("tr").find(".stop").replaceWith('已启用');
> $(that).replaceWith('停用');
> console.log($(that));
>
>
>
> },
> 'click .disable': function(e, value, row, index) {
> var that = $(this);
>
> $(that).closest("tr").find(".start").replaceWith('已停用');
> $(that).replaceWith('启用');
>
> }
目前用了relaceWith方法替换所选择的元素,但是事件也销毁了,请问大家有什么好的办法。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
代码没看太懂,如果是绑定事件的DOM结构被拿掉了的话,可以绑到它的父级做事件代理。
另外,事件处理里的this已经被$包装过也缓存过了,就不要再次包装了吧。
可以使用事件代理,给元素的父元素绑定时间