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 7999881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:37:49+00:00 2026-06-04T15:37:49+00:00

Here i am trying to make a facebook like button . Here is my

  • 0

Here i am trying to make a facebook like button . Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>like button</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<style>
    #like {
        height: 215px;
        background: url(images/sprite.png) no-repeat;
        background-position: 0px 0px;
    }
</style>
<script type="text/javascript">
    $(document).ready(function(){
        $("#like").click(function(){
            $("#like").css("background-position","0px -225px");
        });
    });
</script>
</head>
<body>
    <div id="like">
    </div>
</body>
</html>

Now the picture will change when a user click on that. i want to change that picture vice versa . How can i? is there any other perfect way to implement this?

  • 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-06-04T15:37:50+00:00Added an answer on June 4, 2026 at 3:37 pm

    Define 2 CSS classes (one for Active state and 2nd for Other state) and have relevant CSS ( load image from the sprite image) . Use those on the button/like image click event. Something like this

    CSS

    .stateA,.stateB
    {
      background-image:url('http://www.wing-co.jp/img/ui/site_skin/default/sprite_facebook.png');
      width:20px;  height:20px;       
    }
    
    .stateA
    {  
      background-position:-511px -212px;    
    }
    .stateB
    {
      background-position:-498px -212px;    
    }
    

    HTML

    <input type="button" id="btnLike" class="stateA" value="" />
    

    Javascript

    $(function(){
    
        $("#btnLike").click(function(e){
          e.preventDefault();
          var item=$(this);
          if(item.attr("class")=="stateA")
          {
             item.removeClass("stateA").addClass("stateB");
             //If you want to update database,you can make an ajax call here
          }
          else
          {
             item.removeClass("stateB").addClass("stateA");
             //If you want to update database,you can make an ajax call here
          }
      });   
    
    });
    

    Working Sample : http://jsfiddle.net/cGWTM/32/

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

Sidebar

Related Questions

Here's the code I'm currently working with: http://jsfiddle.net/gEMCm/ I'm trying to make an image
Trying to make a toggle button that hides/shows the right window/pane. Here is a
I can make a search query using these tokens here: http://developers.facebook.com/docs/api#search in the links:
im trying to make a facebook like blue bar. So, i noticed they make
Trying to make a simple jquery drop down here, here's my code so far:
I am trying to make something look like following (don't concern color here. my
If I try and make a facebook like button to like the following url:
Here's the code I'm trying to make work: <?php class database { var $connection;
I'm trying to make something similar to facebook timeline here but for some reason
am trying to make a worker thread using MFC so here is the codes:

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.