我在點擊按鈕上擴展和摺疊文本時遇到問題。當你點擊按鈕時,我能夠做到這一點,文本崩潰,但我也需要這樣做,所以你可以把它展開。我需要首先將它隱藏起來,當你點擊按鈕時,它會消耗掉,然後你可以再次摺疊它。這裏是我的代碼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