![](/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.