Aktualisierung der text für ein Abzeichen im bootstrap-button?

Mit einem click-Ereignis ich bin versucht, zu aktualisieren, die beiden Stücke der a-Taste:

  1. Den text der Schaltfläche

  2. Die Abzeichen zählen

Hier ist mein HTML:

<button class="btn btn-sm btn-default like-btn" type="button" id="10">     
  <span class="glyphicon glyphicon-thumbs-up"></span>Liked
  <span class="badge like-badge active"> 1</span>
</button>

Beim Aufruf der jquery-code es ist Rückkehr die beiden Stücke von text (z.B.: "Gefallen 1")

$(document).on("click", ".like-btn", function(e) {
        e.preventDefault ();

        var btnID = $(this).attr('id');
        var likeText = $(this).text();

        console.log("TEXT: " + likeText);

        if ($(this).hasClass('active')) {
            //How Do I decrement the count and change the "Liked" text to "Like" ?
        }
        else {
           //How Do I increment the count and change the "Like" text to "Liked" ?
        }
    });

Irgendwelche Gedanken?

Dank

InformationsquelleAutor Paul | 2015-02-13
Schreibe einen Kommentar