Created
January 13, 2022 07:34
-
-
Save hogashi/2bfe8cf647a47fb0e7e050189b6ab527 to your computer and use it in GitHub Desktop.
文字を共感覚に沿った色にする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| color = { | |
| 0: 'black', | |
| 1: 'white', | |
| 2: 'yellow', | |
| 3: 'lightgreen', | |
| 4: 'pink', | |
| 5: 'blue', | |
| 6: 'red', | |
| 7: 'lightgreen', | |
| 8: 'black', | |
| 9: 'brown', | |
| }; | |
| newhtml = $0.textContent.split('').map(c => `<span style="color: ${color[c] ? color[c] : 'inherit'}">${c}</span>`).join(''); | |
| $0.innerHTML = newhtml; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment