如何修复jQuery 3.4中已弃用的:eq选择器 [英] how to fix deprecated :eq selector in jquery 3.4
本文介绍了如何修复jQuery 3.4中已弃用的:eq选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
自jQuery 3.4起,不推荐使用:eq
,而应使用 .eq()
.
As of jQuery 3.4 :eq
is being deprecated and instead .eq()
should be used.
这是一个代码片段,其中包含多个使用:eq
的jQuery选择器.我该如何中断多个选择器以使用 .eq()
而不是:eq
?
Here is a code snippet which has multiple jQuery selectors which are using :eq
. How can I break multiple selectors to use .eq()
instead of :eq
?
$(this).find('th.draggable:visible:eq(' + n + ') span,td:visible:eq(' + (g.actionSpan + n) + ') span'));
推荐答案
使用 add()
const $th = $('th.draggable:visible',this).eq(n);
const $td = $('td:visible',this).eq(g.actionSpan + n);
const $spans = $('span',$th).add('span',$td)
这篇关于如何修复jQuery 3.4中已弃用的:eq选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文