有应该获取其信息的人员列表。我对该列表做了简单的分页。但是,列表看起来不错,但是在第一页之后这些按钮不起作用。
这是HTML代码:
<div id="test-list">
<input type="text" class="search" style="width: 50%" placeholder="Search..." /><br><br>
<ul class="list" style="list-style-type:none; margin-left: -40px; margin-bottom: 0px">
<li style="margin-bottom: 0px"><button id="people_1" class="btn btnlink name">People 1</button></li>
<li style="margin-bottom: 0px"><button id="people_1" class="btn btnlink name">People 1</button></li>
<li style="margin-bottom: 0px"><button id="people_2" class="btn btnlink name">People 2</button></li>
<li style="margin-bottom: 0px"><button id="people_3" class="btn btnlink name">People 3</button></li>
<li style="margin-bottom: 0px"><button id="people_4" class="btn btnlink name">People 4</button></li>
<li style="margin-bottom: 0px"><button id="people_5" class="btn btnlink name">People 5</button></li>
<li style="margin-bottom: 0px"><button id="people_6" class="btn btnlink name">People 6</button></li>
<li style="margin-bottom: 0px"><button id="people_7" class="btn btnlink name">People 7</button></li>
<li style="margin-bottom: 0px"><button id="people_8" class="btn btnlink name">People 8</button></li>
<li style="margin-bottom: 0px"><button id="people_9" class="btn btnlink name">People 9</button></li>
<li style="margin-bottom: 0px"><button id="people_10" class="btn btnlink name">People 10</button></li>
</ul>
<ul class="pagination" style="margin-left: 40%"></ul>
</div>
图书馆:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/list.js/1.5.0/list.min.js"></script>
这是jQuery代码:
var monkeyList = new List('test-list', {
valueNames: ['name'],
page: 5,
pagination: true,
});
单击按钮:
$(document).ready(function() {
$(".btnlink").on("click", function(){
var id = $(this).attr('id');
alert(id);
});
});
在第一页之后,单击按钮不会发出警报,不起作用;
我还尝试了事件绑定功能,但也无法正常工作。