Ich bin neu in Jquery und Ajax, ich würde gerne etwas Hilfe erhalten.Wie man Knopf wie ändert?
Wie konnte ich in diesem jQuery-Code hinzufügen:
$('.btn-likes').on('click', function() {
$(this).toggleClass('liked');
});
diese Logik?
function addLikes(id,action) {
$('.demo-table #tutorial-'+id+' li').each(function(index) {
$(this).addClass('selected');
$('#tutorial-'+id+' #rating').val((index+1));
if(index == $('.demo-table #tutorial-'+id+' li').index(obj)) {
return false; }});
$.ajax({
url: "add_likes.php",
data:'id='+id+'&action='+action,
type: "POST",
beforeSend: function(){
$('#tutorial-'+id+' .btn-likes').html("<img src='LoaderIcon.gif' />");},
success: function(data){
var likes = parseInt($('#likes-'+id).val());
switch(action) {
case "like":
$('#tutorial-'+id+' .btn-likes').html('<input type="button" title="Unlike" class="unlike" onClick="addLikes('+id+',\'unlike\')" />');
likes = likes+1;break;
case "unlike":
$('#tutorial-'+id+' .btn-likes').html('<input type="button" title="Like" class="like" onClick="addLikes('+id+',\'like\')" />')
likes = likes-1;break;}
$('#likes-'+id).val(likes);
if(likes>0) {
$('#tutorial-'+id+' .label-likes').html(likes+" Like(s)");
} else {$('#tutorial-'+id+' .label-likes').html('');}}});
}
Ich brauche es für die Änderung der Schaltfläche Animationsstil. Danke.
den großen blob in den kleineren schneiden/einfügen? –
Ich möchte "wie Animation" aus diesem Code ändern: http://phppot.com/jquery/facebook-style-like-unlike-using-php-jquery/ wie diese http://codepen.io/dubstrike/Stift/wMBjLz –