寻找;“显示更多”&引用;隐藏“;javascript/jquery
我在谷歌上搜索了一整天,基本上我有一个字段,可以有50到500个字符,所以我正在寻找一个脚本,允许我一次显示200个字符(例如),并带有一个阅读更多链接来扩展其余内容,到目前为止,我找到的最接近的是这个(见下面的代码)但这需要手动分离内容,这实际上是不可能的寻找;“显示更多”&引用;隐藏“;javascript/jquery,javascript,jquery,Javascript,Jquery,我在谷歌上搜索了一整天,基本上我有一个字段,可以有50到500个字符,所以我正在寻找一个脚本,允许我一次显示200个字符(例如),并带有一个阅读更多链接来扩展其余内容,到目前为止,我找到的最接近的是这个(见下面的代码)但这需要手动分离内容,这实际上是不可能的 <p>...This is all visible content... <a href="#" id="example-show" class="showLink" onclick="showHide('examp
<p>...This is all visible content...
<a href="#" id="example-show" class="showLink"
onclick="showHide('example');return false;">See more.</a>
</p>
<div id="example" class="more">
<p>...This content is hidden by default...</p>
<p><a href="#" id="example-hide" class="hideLink"
onclick="showHide('example');return false;">Hide this content.</a></p>
…这是所有可见的内容。。。
…默认情况下,此内容是隐藏的
在那里我需要像
<div class="hidden"><?php $rows['content']; ?></div>
即使有一个非脚本PHP的方式来做到这一点,我会很高兴。
Html
<div class="box">
<p id="id_full_text" class="class_full_text">
Full Text
<p>
<a href="id_link_show_more" class="class_link_show_more">Show more</a>
<p id="id_hide_text" class="class_hide_text">
Hide Text
<p>
<a href="id_link_hide" class="class_link_hide">Hide more</a>
</div>
Jquery(在同一页面中只有1个)
Jquery(如果您在同一页面中有多个,因为您不想打开页面中的所有隐藏div)
注意:节目中的数字(x)是显示div的时间(毫秒)有很多方法可以做到这一点:并仔细查看
.class_hide_text, .class_link_hide {display: none;}
$('#id_link_show_more').click(function () {
$('#id_full_text').hide(); // hide fullText p
$('#id_link_show_more').hide(); //hide show button
$('#id_hide_text').show('100'); // Show HideText p
$('#id_link_hide').show('100'); // show link hide
});
$('#id_link_hide').click(function () {
$('#id_link_hide').hide(); // hide link hide
$('#id_hide_text').hide(); // hide the hide Text
$('#id_link_show_more').show('100'); //show ths show button
$('#id_full_text').show('100'); // show fullText
});
$('.class_link_show_more').click(function () {
var the_parent = $(this).parent();
the_parent.children('.class_full_text').hide(); // hide fullText p
the_parent.children('.class_link_show_more').hide(); //hide button
the_parent.children('.class_link_hide').show('100'); // Show HideText p
the_parent.children('.class_hide_text').show('100'); // Show HideText p
});
$('.class_link_hide').click(function () {
var the_parent = $(this).parent();
the_parent.children('.class_link_hide').hide(); // hide link hide
the_parent.children('.class_hide_text').hide(); // hide hide text p
the_parent.children('.class_link_show_more').show('100'); //Show link show
the_parent.children('.class_full_text').show('100;); // show full text
});