Jquery:有没有其他方法可以写这个,也许可以使用.attr

Jquery: is there another way to write this, maybe using .attr?

本文关键字:也许 可以使 attr 有没有 其他 方法 Jquery      更新时间:2023-09-26

我想我可以重写下面的行:

$('a').filter('[hash=' + inview + ']');

类似的东西:

$('a').attr(href, inview);

显然与上面定义的CCD_ 1有关

或者有没有其他方法可以把第一行写在那里,

使用jquery并为.attr或.esomething(inview(之类的东西去掉[hash='

$('a[hash=' + inview + ']');

这样就可以了。

您想要类似以下内容:

$('a[hash="' + inview + '"]')

$('a').attr('hash', inview);,也就是我认为您对第二行的意思,实际上散列属性设置为inview。

$('a').attr(href, inview);

用于将所有a元素的href设置为inview 的参考