Jump to content

php and jquery button


Recommended Posts

I have this button for my like system and for some reason i have to refresh after i click it again... i would like it to be that when i click it it changes the class and i can click it again and do the other function... please help thank you... 




<script type="text/javascript">
 $('[name="like"]').on("click", function(){
    $('[name="unlike"]').on("click", function(){


$likes = mysql_query("SELECT lid FROM likes WHERE uid='$id' AND imid='$photoid'");
$likethis = '<div class="like" title="like" id="'.$photoid.'" name="like"></div>';
$unlikethis = '<div class="unlike" title="unlike" id="'.$photoid.'" name="unlike"></div>';


Link to comment
Share on other sites

That [name=like] selector you have only applies when adding the event handler. Changing the name won't suddenly make the other handler be applied to it.


Use just one handler for both like and unlike, and use the class/title/name to decide what action to take.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.