我正在使用展开折叠在我的网站上使用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>
但是当我在全文中使用表时,它就停止工作了。请提出任何建议。
2条答案
按热度按时间bqujaahr1#
将
<p class="fulltext">
改为<div class="fulltext">
,它应该可以正常工作。在<p>
中不能有其他块元素。rjee0c152#
<div>
元素用于描述数据容器,而<p>
元素用于描述内容段落。若要使用内部表格,请使用div
标记。Fiddle