I'm trying to change text on click. First click "show", next click "hide". I can't figure out what is wrong here.
$(document).ready(function() {
$(".card-link:first").click(function() {
if ($(".card-link:first").text('Show comments')) {
$("ul.list-group.list-group-flush").show();
$(".card-link:first").text('Hide comments');
} else if ($(".card-link:first").text('Hide comments')) {
$("ul.list-group.list-group-flush").hide();
$(".card-link:first").text('Show comments');
}
});
});
JSfiddle: https://jsfiddle.net/eyc4kxzm/6/
if ($('.card-link:first').text('Show comments'))this is not how you test if an element contains a texttidybutton on top - for the code snipped here on SO