当我单击按钮时,我只想在列表中显示所需数量的元素(比如根据输入条件显示 3 个项目)我将如何完成它?
$(document).ready(function () {
var list = $('#myList li:gt(0)');
list.hide();
$('a#myList-toggle').click(function () {
var username = $("#<%= uname.ClientID %>").val();
var pwd = $("#<%= pwd.ClientID %>").val();
var ints = $("#<%= uname.ClientID %>").val();
var list1 = $('#myList li:gt(3)');
alert(username);
list.slideToggle(400);
return false;
});
});
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<a href="#" id="myList-toggle">Show the rest</a>
UserName:
<asp:TextBox id="uname" Text="" runat="server" />
PassWord : <asp:TextBox id="pwd" Text="" runat="server"/>
<ul id="myList" style="margin-bottom: 0px" >
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
<asp:Button id="Login" Text="Login" runat="server" />
</asp:Content>