因此,我对理解JQuery以及如何执行“显示更多”功能有点麻烦。这里是我的工作我的HTML文件,该文件是从Murach JQuery的书JQuery“显示更多”功能
<main id="jdom">
<h1>Murach's JavaScript and DOM Scripting</h1>
<h2>Book description</h2>
<div>
<p>You can read other JavaScript books from start to finish and still not
know how to develop dynamic websites like you want to. That's because
it's DOM scripting that lets you do things like run slide shows, handle image
rollovers, rotate headlines, provide animation, and more. And it's a subject
that's glossed over or ignored in most other books.</p>
</div>
<div class="hide">
<p>But now, you can go from JavaScript beginner to DOM scripting expert in a
single book! Fast-paced, professional, and packed with expert practices, our
new JavaScript book guides you through each step as you learn how to program
sites that enhance the user experience and ensure browser compatibility.</p>
</div>
<a href="#">Show more</a>
这里是Jquery的我与
$(document).ready(function() {
$("a").click(function() {
$(this).toggleClass("hide");
if ($(this).attr("class") != "hide") {
$(this).next().hide();
}
else {
$(this).next().show();
}
});
});
工作,所以我有一个小麻烦察觉的bug的代码。如果我错误地将类隐藏到classToggle方法中。任何帮助,更深入了解我会出错的地方将不胜感激!
你想在点击时显示'.hide'类文字看更多? –
这就是我要去的 –
[阅读更多/更少的jQuery手风琴]可能的重复(http://stackoverflow.com/questions/19324740/read-more-less-jquery-accordion) –