[英]How to change the title and html on slideToggle
我有這個HTML標記:
<a title="Hide comments" hreflang="1" class="comment-show-link" rel="tooltip" href="">Hide comments</a>
<a title="Hide comments" hreflang="2" class="comment-show-link" rel="tooltip" href="">Hide comments</a>
我想在slideToggle上將標題和HTML更改為“顯示評論”,但不知道如何。 我寫這段代碼來顯示/隱藏DIV:
$('.comment-show-link').click(function(e) {
$('#comment-show-'+$(this).attr("hreflang")).slideToggle('slow');
e.preventDefault();
});
但不知道如何檢查DIV是隱藏還是可見,並且在每種情況下都會更改標題和HTML。 另外我知道我可以使用text()或html()jQuery函數來實現這個但是怎么做? 有幫助嗎?
提前致謝
嘗試這個:
$('.comment-show-link').click(function(e) {
var $this = $(this);
var num = $this.attr('hreflang');
$('#comment-show-'+num).slideToggle('slow', function(){
if ($(this).is(':hidden')) {
// do something here
// $this.attr('...', '...')
}
});
e.preventDefault();
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.