我想通過從這段代碼中提取出來將12.5的值設置爲一個變量。如何找到一個元素的innerHTML
<li style="background-color: transparent;">
<a href="#userModal" data-toggle="modal" data-target="#userModal"></a>
<span style="background-color:#FDBF6F"></span>
12.5 GoCoins
</li>
我試過做一些研究,但無法讓我的頭圍繞它,幫助讚賞。
var inthepot = 0
inthepot = +(document.querySelector("li")[0].innerHTML)
什麼是'inthepot'? – Li357
它只是一個變量 – Recuvan
只需使用'textContent'而不是'innerHTML' – Rayon