私はクリック時にテキストを変更しようとしています。最初に"show"
をクリックし、次に"hide"
をクリックします。ここで何が間違っているのか分かりません。(jQuery)クリック時にテキストを変更します。
$(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/
'場合($(」カードリンク:最初の ')テキスト(' 表示するコメントは))'これが方法ではありませんもしあなたがjsfiddleを使っているので、要素にテキスト – birdspider
が含まれているかどうかをテストしてください。ここでsnipされたコードのために、少なくとも上の 'tidy'ボタンを使いましょう--SO – birdspider