Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
押す前にもっと見るボタンを押してから、押すと非表示にするボタンを実行しようとしています。問題は、[非表示] を押しても [もっと見る] に戻らないことです。どうすればこれを解決できますか?
jQuery コードは次のとおりです。
$("#single .vm").click(function () { $("#singlemore").slideToggle(150); $("#single .vm").html('Hide'); });
View more三項演算子を使用してテキストを切り替え、 $("#single .vm") の代わりにHide使用できます$(this)
View more
Hide
$(this)
$("#single .vm").click(function () { $("#singlemore").slideToggle(150); $(this).html($(this).html() == 'Hide' ? 'View more' : 'Hide'); });