Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6991179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:27:44+00:00 2026-05-27T19:27:44+00:00

I have a simple div that i use to trigger an ajax post. I

  • 0

I have a simple div that i use to trigger an ajax post. I call the object by one of it’s classes when it is clicked. When i submit and render the same object again i dont want it to be clickable so i remove the class from the object but it still is clicking even though in the dom it is gone. Any ideas how to prevent the object from being clicked again?

The Ajax post works fine just trying to figure out how to stop another click after the submit is complete.

Code:

HTML:

<div class="likeContent">
    <div class="bylineBox right likeThisLink" id="like-this-<?php echo get_comment_ID(); ?>">
         <a href="#" onclick="return false;" class="likeThisContent">
             <span>
                 <img src="<?php bloginfo('template_url'); ?>/images/like-icon.png" alt="Like" />
                 <?php if ($current_like_count[0] > 0) { echo $current_like_count[0];} else {echo 'Like';} ?>
             </span>
         </a>
    </div>
</div>

JS (Jquery function):

$('.likeThisLink').click(function(e) {
    var contentID = $(this).attr("id").split("-")[2];
    var siteURL = $('.siteURL').attr("id");
    var templateURL = $('.templateURL').attr("id");
    var processURL = siteURL + "/wp-admin/admin-ajax.php"
     $.post(processURL,{
      action: 'my_unique_action',
      content_id: contentID },  
      function(data) {  
        var currentLikeCount = $('.likeCount-' + contentID).attr("id").split("-")[1];
        var newLikeCount = parseInt(currentLikeCount) + 1;
        $('#like-this-'+contentID).fadeOut().html("<a><span><img src=\"" + templateURL + "/images/like-icon.png\" alt=\"Like\" />" + newLikeCount + "</span></a>").fadeIn();
        $('.likeCount-' + contentID).attr("id", "likeCountCurrent-" + newLikeCount);
        e.preventDefault();
      });  
     $(this).removeClass('likeThisLink')
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:27:45+00:00Added an answer on May 27, 2026 at 7:27 pm

    You can use the jQuery one function for this like:

     $(".likeThisLink").one("click", function() {
     ....
    });
    

    The code will only execute once no matter how many times it is clicked. You can read up on it here http://api.jquery.com/one/

    EDIT Alternatively you can unbind the click function like this:

    $('.likeThisLink').unbind('click');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple $.ajax call that returns a response that looks like this:
I am trying to accomplish something that seemed quite simple... I have 3 div
I have simple JavaScript code that is using the Ajax API for fetching a
I have a PHP form that needs some very simple validation on submit. I'd
I have a simple form. Its got one field and a submit button. I
I have a simple page (index.html) with a div: I am populating that div
I have a really simple external css stylesheet that has the following : div.hideBox
I have a simple html page with a div. I am using jQuery to
I have a simple jquery animation on a div, which is inside a div,
I have an anchor tag with some simple CSS: div { background-color: gray; /*

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.