0
我需要幫助querySelectorAll
。有沒有辦法讓函數返回只有我指定的元素?Javascript querySelectorAll僅返回選擇器我指定
即document.querySelectorAll('span.Fz-xxs')
可以返回一個元素<span class="blah1 blah2 Fz-xxs">
,但我只是希望它返回的<span class="Fz-xxs">
我需要幫助querySelectorAll
。有沒有辦法讓函數返回只有我指定的元素?Javascript querySelectorAll僅返回選擇器我指定
即document.querySelectorAll('span.Fz-xxs')
可以返回一個元素<span class="blah1 blah2 Fz-xxs">
,但我只是希望它返回的<span class="Fz-xxs">
要與你想要的類選擇<span>
元素(例如:FX-XXS),沒有別的,你可以使用:
document.querySelectorAll('span[class="Fz-xxs"]')
對於您可以使用:'document.querySelectorAll( '跨度[CLASS = 「FZ-XXS」]')' – techfoobar
完美!如果您將其作爲答案提交,我會接受它 – Bijan