我正在寻找一款可以在
avg website上找到的jQuery手风琴而没有运气,所以我希望有人可以指出我正确的方向.源代码或示例.
我已经有手风琴正在工作,但它是缺少读取的更多/近距离功能,我想使用它.
解决方法
const moreText = "Read more"; const lessText = "Read less"; const moreButton = $("button.readmorebtn"); moreButton.click(function() { const $this = $(this); $this.text($this.text() == moreText ? lessText : moreText).next(".more").slideToggle("fast"); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="wrap"> <p>Duis mollis,est non commodo luctus,nisi erat porttitor ligula,eget lacinia odio sem nec elit. </p> <button class="readmorebtn" type="button">Read more</button> <p class="more" style="display:none">Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor. Lorem ipsum dolor sit amet,consectetur adipiscing elit. Maecenas faucibus mollis interdum. Etiam porta sem malesuada magna mollis euismod. Praesent commodo cursus magna,vel scelerisque nisl consectetur. </p> </div>