jeudi 2 mars 2017

jQuery inline if statement

I am using the following code to toggle the text of an <a> tag:

$(function() {
    $(".button-table-holder").click(function () {
        $('.tableHolder').slideToggle(500);
        return false;
    });

    var text = $('.button-table-holder').text();
    $('.button-table-holder').text(text == "Show full product specifications" ? "Hide" : "Show full product specifications");
});

The text seems to be stuck on Show full product specifications though... I would like it so that it changes whenever I click the link

Aucun commentaire:

Enregistrer un commentaire