<script type="text/javascript">
$(function () {
$.ajax({
url: "/json/json.json",
type: "get",
dataType: "json",
success: function (data) {
var tab = "<table><tr class='head'><th>用户名</th><th>密码</th><th>邮箱</th><th>手机号</th></tr>";
$.each(data, function (i, value) {
tab += '<tr><td>' + value.user + '</td>' + '<td>' + value.password + '</td>' + '<td>' + value.email + '</td>' + '<td>' + value.phone + '</td>' + '</tr>';
});
tab += '</table>';
$(".div").html(tab);
$("#search").click(function () {
var text = $("#text").val().trim();
if (text != '') {
$(".no").remove();
$("table tr:not(.head)").hide().filter(":contains('" + text + "')").show();
} else {
$("table tr:not(.head)").hide();
$(".div").append("<tr class='no'><td clospan='4'>没有该记录</td></tr>");
}
});
}
});
})
$(function () {
$.ajax({
url: "/json/json.json",
type: "get",
dataType: "json",
success: function (data) {
var tab = "<table><tr class='head'><th>用户名</th><th>密码</th><th>邮箱</th><th>手机号</th></tr>";
$.each(data, function (i, value) {
tab += '<tr><td>' + value.user + '</td>' + '<td>' + value.password + '</td>' + '<td>' + value.email + '</td>' + '<td>' + value.phone + '</td>' + '</tr>';
});
tab += '</table>';
$(".div").html(tab);
$("#search").click(function () {
var text = $("#text").val().trim();
if (text != '') {
$(".no").remove();
$("table tr:not(.head)").hide().filter(":contains('" + text + "')").show();
} else {
$("table tr:not(.head)").hide();
$(".div").append("<tr class='no'><td clospan='4'>没有该记录</td></tr>");
}
});
}
});
})
</script>
<form id="form1" runat="server">
<input type="text" id="text" value=" 用"/><input type="button" value="查询" id="search" />
<div class="div"></div>
</form>