我正在处理一个相当大的项目,我在阅读更多按钮时遇到问题,我对javascript很陌生,并且仍然试图解决这个问题。我已经为第一个按钮工作的功能,但它对其他人不起作用,你能告诉我我做错了什么吗。
$(document).ready(function() {
$("#read").click(function() {
$(this).prev().toggle();
$(this).siblings('.dots').
toggle("read");
if ($(this).text() == 'Read More') {
$(this).text('Read Less');
} else {
$(this).text('Read More');
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h1>The Hound Group</h1>
<div class="container">
<h3>The Sighthounds</h3>
<p>
By definition, a sighthound is simply a dog breed that hunts primarily by sight and speed rather than by scent because of this they are sometimes refered to as Gazehounds. Because sighthounds hunt by sight, they need to have the speed and agility to keep
up with their prey in order to keep them in sight. Sighthound breeds typically have lean bodies, long legs, and a flexible back – they also have deep chests to support their unusually large hearts and lungs. To help you picture the typical sighthound
body, here is a list of breeds that are categorized as sighthounds:
<h4>Afghan Hound:</h4>
<p>
Wow very biscit stop it fren very hand that feed shibe heckin, many pats. Shooberino h*ck blep shoob sub woofer very taste wow shoober, snoot heckin mlem smol borking doggo with a long snoot for pats. Heck I am bekom fat pupperino borkdrive length boy,
such treat maximum borkdrive wow very biscit. Borking doggo clouds much ruin diet pupperino tungg super chub, very hand that feed shibe you are doin me a concern boofers
它适用于第一段,但不适用于第二段,你能告诉我为什么或者是否有更好的方法来做到这一点吗?谢谢
慕妹3242003
小唯快跑啊
相关分类