Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
cambiando el HTML interno de los párrafos adjuntos de jquery Javascript

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!