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

  • SEARCH
  • Home
  • 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 7006725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:30:52+00:00 2026-05-27T21:30:52+00:00

Once you click to up-vote it becomes enabled, it can only be disabled by

  • 0

Once you click to up-vote it becomes enabled, it can only be disabled by clicking the down-vote. How do I make it so that if I click to an enabled button it will become disabled.

$("a.vote_down").click(function() {
    //get the id
    the_id = $(this).attr('id');

    //the main ajax request
    $.ajax({
        type: "POST",
        data: "action=vote_down&id="+$(this).attr("id"),
        url: "votes.php",
        success: function(msg) {
            $(".vote_down").addClass("active");
            $(".vote_up").removeClass("active");
            $("span#votes_count").html(msg);
        }
    });
});

One of the links:

<a href='javascript:;' class='vote_up<?php if($liked["points"]=="1") echo " active";?>' id='<?php echo $id; ?>'>Vote Up</a>
  • 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-27T21:30:53+00:00Added an answer on May 27, 2026 at 9:30 pm

    Try using this as a live click event on the active class. Added some abstraction.

    $("a.vote_down.active").live("click", function(e) {
        Vote($(this).attr('id'), false);
    });
    
    $("a.vote_up.active").live("click", function(e) {
        Vote($(this).attr('id'), true);
    });
    
    function Vote(id, value) {
        //the main ajax request
        var action = value ? "vote_up" : "vote_down"
        $.ajax({
            type: "POST",
            data: "action=" + action + "&id=" + id,
            url: "votes.php",
            success: function(msg) {
                $(".vote_down").toggleClass("active", value);
                $(".vote_up").toggleClass("active", !value);
                $("span#votes_count").html(msg);
            }
        });
    }
    

    working example: http://jsfiddle.net/hunter/XQfgU/ (minus the AJAX)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is that I can only seem to click the button once, if
It only works once. At second button click, nothing occurs. If I change budilnik
once i click button, my image1 will display an image; when i set my
I want to write a console or Click Once WinForms app that will programmatically
I am working on a project that is click-once deployed from an IIS 7.5
I'm working with an aspx page, where once I click on a button, some
I am having a problem after opening the notepad once I click the button
I want to change the BackgroundImage of a button when you click once, and
I have a click once application that that is installed from a page, is
I have a Click Once App that has been published to the same location

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.