Así que recientemente aprendí a usar jquery para agregar un párrafo a un div. Sin embargo, cuando quiero actualizar el párrafo adjunto con document.getElementById.innerHTML, parece que no funciona. ¿Cómo puedo solucionar esto?
const priceList = document.getElementById("pricebar"); var coinlist = ["BTC", "ETH", "LUNA", "LYXE", "ATOM", "SOL", "AVAX"]; var coinIds = []; var delayTime = 2000; const coinNamesAndPrices = document.getElementsByClassName("pricebardata"); const heyyy = document.getElementById("test"); var amountofCalls = 0; getCoinPrices(); window.setInterval(function() { amountofCalls += 1; getCoinPrices(); console.log(amountofCalls); }, delayTime); function getCoinPrices(){ var xmlhttp = new XMLHttpRequest(); var coinPrices; var url = "https://api.nomics.com/v1/currencies/ticker?key=(keyname)=" + coinlist.join(); var jsonData; xmlhttp.onreadystatechange = function(){ if (this.readyState == 4 && this.status == 200){ var json = JSON.parse(this.responseText); jsonData = parseJson(json); } } xmlhttp.open("GET", url, true); xmlhttp.send(); } function parseJson(json){ var coinIds = []; var coinPrices = []; for (i=0; i<coinlist.length; i++){ coinIds.push(String(json[i]["id"])); coinPrices.push(String(json[i]["price"])); } var coinPricesInt = coinPrices.map(Number); var coinPricesRounded2Decimals = coinPricesInt.map(function roundPrices2Decimals(price){ return price.toFixed(2); //return Math.round(price * 100)/100 }) if (amountofCalls == 0){ addPriceDataHTML(coinPricesRounded2Decimals, coinIds); } else { console.log(coinPricesRounded2Decimals); coinNamesAndPrices.innerHTML = coinIds[i] + ":" + " " + "$" + coinPricesRounded2Decimals[i]; } } function addPriceDataHTML(coinPriceDollars, coinNames){ for (i=0; i<coinNames.length; i++){ $("#pricebar").append('<p class="pricebardata">' + coinNames[i] + ":" + " " + "$" + coinPriceDollars[i] + '</p>'); } } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="pricebar"> *appended paragraphs with classnames which I want to edit here* </div>¡Realmente agradecería cualquier ayuda que pueda obtener! Gracias