[英]querySelectorAll does not work with pseudo class nth-last-child
我有這個javascript代碼:
var fieldsets = document.querySelectorAll('fieldset:nth-last-child("-n+2")');
console.log('fieldsets' + fieldsets);
我有4個字段集
我在Chrome檢查器中收到此錯誤:
Uncaught SyntaxError: Failed to execute 'querySelectorAll' on 'Document': 'fieldset:nth-last-child("-n+2")' is not a valid selector.
我希望有人能幫幫忙! 謝謝 :)!
您不需要參數表達式周圍的引號。
var fieldsets = document.querySelectorAll('fieldset:nth-last-child(-n+2)');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.