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

292
Views
How can i replace complete html including tags and other stuf?

I want to change or replace complete html tag not just inner it :

 function addToLikes(image_id) {
        $.ajax({
            url: 'functions/addToLikes.php',
            method: 'POST',
            data: {
                image_id: image_id
            },
            success: function(data) {
                document.getElementById(image_id).innerHTML = `<i class="bi bi-heart-fill ms-3" onclick="removeFromLikes('<?php echo $row['image_id'] ?>')" style="cursor:pointer"></i>`;
            }
        });
    }

HTML

 <i class="bi bi-heart ms-3" id="<?php echo $row['image_id'] ?>" onclick="addToLikes('<?php echo $row['image_id'] ?>')" style="cursor:pointer"></i>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is a better way - much faster and does not make the DOM flicker

$(".bi").on("click",  function(e) {
  const $this = $(this)
  const liked = $this.hasClass("bi-heart-fill");
  $.post("functions/toggleLikes.php', { id: $this.data("id"), liked:liked },function() {
    liked = !liked;
    $this.toggleClass("bi-heart-fill",liked)
    $this.toggleClass("bi-heart",!liked)
  })
})
  <i class="bi bi-heart<?= $liked?"fill":"" ?> ms-3" data-id="<?php echo $row['image_id'] ?>" style="cursor:pointer"></i>
</div>
about 4 years ago · Juan Pablo Isaza Report
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!