• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript problem with special characters


New Coder
Hello all,

I am trying to make a Chrome extension for a collectible card game that is going to need to involve getting the inner text of all divs with the class "team__monster__level". All of them have have a star special character followed by a number as their inner text. I need the number. But when I try to get the inner text using this code:

function insertScript() {
 chrome.tabs.query({active: true, currentWindow: true}, tabs => {
 chrome.scripting.executeScript({target: {tabId: tabs[0].id}, function: getData})
document.getElementById('buttonTwo').addEventListener('click', insertScript)
function getData() {

    elements = document.getElementsByClassName('team__monster__level');
    allInnerHTML = '';

    for (index in elements) {
        var element = elements[index];
        allInnerHTML = allInnerHTML+" "+element.innerHTML;

I just get "undefined" for each element. I'm pretty sure this is because of the star character, because when I switch the class name to refer to divs that just have text, the code works fine. So how do I just get the number that I need?