简体   繁体   中英

How will I write special characters written in my HTML code in Javascript?

I wrote a special character in my HTML - &#873 to get a square root symbol. I am trying to get that button using innerText using javascript but it doesn't mean to work.

```else if (x.target.innerText == "&#8730"){
console.log("H")
    }
```

check out the code

Browsers normalise HTML when they convert it to a DOM.
so it is better to compare the text:

if ($(this).text() === "√"){

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM