JQuery 표 내용 필터 링 실현 방법

2867 단어 JQuery내용.여과

[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JQuery </title>
<style type="text/css">
table{ border:0;border-collapse:collapse;}
div{font:normal 12px/17px Arial;}
td{ font:normal 12px/17px Arial;padding:2px;width:100px;}
th{ font:bold 12px/17px Arial;text-align:left;padding:4px;border-bottom:1px solid #333;width:100px;}
.even{ background:#FFF38F;}  /* */
.odd{ background:#FFFFEE;}   /* */
.selected{ background:#FF6500;color:#fff;}
</style>
<!--   jQuery -->
<script src="jquery-1.5.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
  $(function(){
       $("#filterName").keyup(function(){
          $("table tbody tr")
                    .hide()
                    .filter(":contains('"+( $(this).val() )+"')")
                    .show();
       }).keyup();
  })
</script>
</head>
<body>
    <div> <br/> : <input id="filterName" name="filterName" /> <br/> </div>
    <table>
        <thead>
            <tr><th> </th><th> </th><th> </th></tr>
        </thead>
        <tbody>
            <tr><td>SYJ</td><td> </td><td> </td></tr>
            <tr><td> </td><td> </td><td> </td></tr>
            <tr><td> </td><td> </td><td> </td></tr>
            <tr><td> </td><td> </td><td> </td></tr>
            <tr><td> </td><td> </td><td> </td></tr>
            <tr><td> </td><td> </td><td> </td></tr>
            <tr><td> </td><td> </td><td> </td></tr>
            <tr><td> </td><td> </td><td> </td></tr>
            <tr><td> </td><td> </td><td> </td></tr>
        </tbody>
    </table>
</body>
</html>

좋은 웹페이지 즐겨찾기