我在点击按钮上扩展和折叠文本时遇到问题。当你点击按钮时,我能够做到这一点,文本崩溃,但我也需要这样做,所以你可以把它展开。我需要首先将它隐藏起来,当你点击按钮时,它会消耗掉,然后你可以再次折叠它。这里是我的代码jQuery展开和折叠文本
$(document).ready(function() {
$('#btnSlideUp').click(function() {
$('#p1').slideUp(1000);
});
$('#btnSlideDown').click(function() {
$('#p1').slideDown(1000);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<button id="btnSlideUp" class="btn btn-outline-success"><h1 class="jumbotron-heading">Expand</h1></button>
<p class="lead text-muted" id="p1">Below this post you can find different articles, tips&tricks about how to find the job. You can try to contact us, and we will greatly try to answer all of your questions. You can click on "Start finding a job" and we will take you through the basics
of finding a job, from the beginning till the end if you have absolutely no excperience.</p>
<p>
<a href="contactus.html"><button type="button" class="btn btn-
outline-primary btn-lg">Contact Us</button></a>
<a href="path.html"><button type="button" class="btn btn-outline
secondary btn-lg">Start finding a job</button></a>
</p>
</div>
好吧,你的答案,因为我认为最适合我,但很快的问题,如何使页面加载时隐藏文本,然后用户点击扩大它的文本显示了? – iKON1K
@ iKON1K使用** CSS **属性'display:none',&当用户点击*展开*使用这个:'$('#p1')。show()' –
好吧,它的工作,非常感谢你许多 – iKON1K