JavaScript and jQuery newbie here, and I wanted to ask a question; Basically, I have a list and only 1 element of it is displayed at any given time, but the problem is - when I get to the end of the list, and I want to display the next element and hide the current element, than everything becomes hidden. here s the code:
说到底,我可以使用最后(最后)确定最后一个要素,给它一个身份证,如果该身份证是最后要素,则不执行指挥,但我确实不知道 Java的辛子。
传真:
<style>
#
#container li .active
{
display:inline-block;
}
#container li .inactive
{
display:none;
}
</style>
</head>
<body>
<ul id="container">
<il class= active >item I</il>
<il class= inactive >item II</il>
<il class= inactive >item III</il>
<il class= inactive >item IIII</il>
<il class= inactive >item IV</il>
</ul>
<span id= next >Next</span>
<span id= prev >Previous</span>
<script>
$(".inactive").hide();
$(".active").show();
$("#next").click(function()
{
var nexte=$(".active");
nexte.addClass("inactive");
nexte.removeClass("active")
nexte.next(".inactive").addClass("active");
nexte.next(".inactive").removeClass("inactive");
$(".inactive").hide( slow );
$(".active").show( slow );
});
$("#prev").click(function()
{
var preve=$(".active");
preve.addClass("inactive");
preve.removeClass("active")
preve.prev(".inactive").addClass("active");
preve.prev(".inactive").removeClass("inactive");
$(".inactive").hide( slow );
$(".active").show( slow );
});
</script>
事先感谢它。