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

161
Views
Cómo limitar la cantidad de veces que se genera el elemento

Tengo este código que muestra los productos junto con su precio. El problema es que cada vez que retrocedo y avanzo se vuelve a sumar el precio. El proyecto en sí se crea a través de archivos .js, por lo que el código de URL no cambia si esa información ayuda.

 function(val) { var products = $('#products'); var children = products.children('#productsUserInputs').children(); for (var i = 0; i < children.length; i++) { var current = children[i]; var currentId = $(current).attr('id').toLowerCase(); var result = val.map(a => (a.Product + 'wrapper').toLowerCase()); var productName = currentId.replace('wrapper', ''); var foundProduct = val.find(e => e.Product.toLowerCase() === productName); if (foundProduct) { var price = foundProduct.Price; var priceDisplay = document.createElement("div"); var priceId = priceDisplay.setAttribute('id', 'price'); priceDisplay.append(price); current.appendChild(priceDisplay); var getprice = document.getElementById('price'); if (getprice > 1) { priceDisplay.setAttribute("class", "hidden"); } else { priceDisplay.setAttribute("class", "display-price"); } } if (result.includes(currentId)) { $(current).attr("hidden", false); } else { $(current).attr("hidden", true); } if (result.includes(!priceDisplay)) { $(priceDisplay).attr("hidden", true); } else { $(priceDisplay).attr("hidden", false); } } }

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!