-1
I made a function that calculates the value received by an input and generates a result that should be shown in a modal, the modal appears with the title and the cute span, but the p with the result does not appear at all, currently the code is like this, but I’ve tried taking the div class "modal-content", the previous div which is the "modal", I also tried with innerText and innerContent and the same thing happened. I’m grateful if anyone can help, the code is just below.
HTML
 <div id="myModal" class="modal">
            <div class="modal-content">
                <span class="close">×</span>
                <h2 class="modal-title">Sua conversão</h2>
                <p class="modal-text"></p>
            </div>
        </div>
        <div class="content">
            <div class="dolar-real">
                <div class="content-text">
                    <p>Dólar para real</p>
                    <img src="./assets/coin.png" alt="Dólar">
                </div>
                <div class="entrada">
                    <input type="text" id="dolarToReal">
                    <button id="btnDolarToReal" onclick="dolarParaReal()"><img src="./assets/Group.png" alt="Botão de conversao"></button>
                </div>
            </div>
        </div>
Javascript
function dolarParaReal() { //Função para calcular e mostrar o resultado
    var valor = document.getElementById('dolarToReal').value;
    var valorNumero = parseFloat(valor);
    var resultado = valorNumero * 5.71;
    var mostrarValor = `O valor convertido é: ${resultado}`;
    document.getElementsByClassName('modal-text').innerHTML = mostrarValor;  
    
    abrirModal();
}
function abrirModal() { //função para abrir o modal
    myModal.style.visibility = "visible";
}
var span = document.getElementsByClassName("close")[0]
span.onclick = function fecharModal() { //função para fechar o modal
    myModal.style.visibility = "hidden";
}
I tried it here and it went on anyway, but it was a good way to summarize the code.
– Juarez Goulart