我有从 json 中获取所有记录的工作代码,但是如何通过单击按钮(下一个/上一个)使记录一一可用?
以下代码正在获取所有记录:
div
{
text-align:center;
padding:10px;
}
#msg {
width: 500px;
margin: 0px auto;
}
.members {
width: 500px ;
background-color: beige;
}
<input type="button" name="next" id="next"><br/>
<input type="button" name="previous" id="previous"><br/>
<div id="msg">
<table id="userdata" border="1">
<thead>
<th>Email</th>
<th>Sex</th>
<th>Location</th>
<th>Picture</th>
<th>audio</th>
<th>video</th>
</thead>
<tbody></tbody>
</table>
</div>
$(document).ready(function(){
var url="json.php";
$("#userdata tbody").html("");
$.getJSON(url,function(data){
$.each(data.members, function(i,user){
var tblRow =
"<tr>"
+"<td>"+user.email+"</td>"
+"<td>"+user.sex+"</td>"
+"<td>"+user.location+"</td>"
+"<td>"+"<img src="+user.image+">"+"</td>"
+"<td>"+"<audio src="+user.video+" controls>"+"</td>"
+"<td>"+"<video src="+user.video+" controls>"+"</td>"
+"</tr>" ;
$(tblRow).appendTo("#userdata tbody");
});
});
});