Skip to content Skip to sidebar Skip to footer

How To Separate A Value From A Class

I want to attempt to get a value from a site and calculate it. At the moment when entering the command document.getElementById('txtTehtav') I recieve the answer along the lines of

Solution 1:

    const textValue = document.getElementById("txtTehtav").innerText; // Will return 3x3=
    const [x, y] = textValue.substr(0, textValue.length - 1).split('x').map((n) => parseInt(n))

const muliplication = x*y;

Solution 2:

Try this, you will get the text

document.getElementById("txtTehtav").textContent

Post a Comment for "How To Separate A Value From A Class"