![](/img/trans.png)
[英]Any way in JavaScript to avoid using setTimeout to execute a function right after another? Maybe with jQuery?
[英]Jquery: is there another way to write this, maybe using .attr?
我想我可以重写下面的行:
$('a').filter('[hash=' + inview + ']');
像这样:
$('a').attr(href, inview);
显然,上面定义了var inview = yada yada yada
。
还是有另一种方法可以在那里写第一行,
使用 jquery 并摆脱像.attr 或.something(inview) 这样的[hash='
?
$('a[hash=' + inview + ']');
那应该这样做。
你想要这样的东西:
$('a[hash="' + inview + '"]')
$('a').attr('hash', inview);
,这就是我假设您对第二行的意思,实际上将hash 属性设置为 inview。
$('a').attr(href, inview);
作为参考,将所有 a 元素的 href 设置为 inview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.