判断checkbox是否选择并且弹出选择的值

来源:互联网 发布:spss19.0破解软件 编辑:程序博客网 时间:2024/05/16 16:17

<!DOCTYPE html>
 <html>
 <head>
     <script src="/jQuery/jquery-1.11.1.min.js">
     </script>
     <script>
         function imgClick(t) {
             if ($('#' + t).prop("checked")) {
                 alert("选中");
                 alert($('#' + t).val());
             }
             else {
                 alert('未选中');
                 alert($('#' + t).val());
             }

         }

    </script>
 </head>
 <body>

    <input type="checkbox" id="ss11" value="30" onclick=imgClick(this.id) name="chk" />
     <input type="checkbox" id="ss12" value="31" onclick=imgClick(this.id) name="chk" />
     <input type="checkbox" id="ss13" value="33" onclick=imgClick(this.id) name="chk" />
 </body>
 </html>


原创粉丝点击