【发布时间】:2013-07-17 07:49:38
【问题描述】:
我在我的网站上使用以下 jquery 和 html 代码展开折叠:
<script>
$(document).ready(function () {
$('.fulltext').hide();
$('.blog-item .readmore').click(function (event) {
event.preventDefault();
$(this).parent().find('.fulltext').slideToggle('slow');
$(this).text($(this).text() == 'Close Deals' ? 'More Deals' : 'Close Deals');
});
});
</script>
HTML:
<div class="blog-item">
<p class='fulltext'>Read more text will be here.</p>
<a class="readmore" href="#">Read more..</a>
</div>
实际上我想在隐藏文本中使用表格,现在是:<p class='fulltext'>Read more text will be here.</p>
但是当我在全文中使用表格时,它会停止工作。请任何建议。
【问题讨论】:
-
你应该使用
prev()而不是parent().find('.fulltext');