jQuery中的val()
2014-02-25 23:06
639 查看
jQuery中的val()
1、实例源码
2、结果如下
(1)选中所有的
依次弹出“篮球、足球和排球”
(2)选中部分
依次弹出相应的值
(3)全不选
不弹窗口
1、实例源码
<!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中的val()</title> <script type="text/javascript" src="jquery-2.1.0.js"></script> <script type="text/javascript"> $(function(){ $("#btn").click(function(){ $("input[name=ckb]:checked").each(function() { alert($(this).val()); }); }); }); </script> </head> <body> <div id="div1"> <table> <tr> <td> <input type="checkbox" id="ckb1" name="ckb" value="篮球"/>篮球 <input type="checkbox" id="ckb2" name="ckb" value="足球"/>足球 <input type="checkbox" id="ckb3" name="ckb" value="排球"/>排球 </td> </tr> <tr> <td> <input type="button" id="btn" value="取值"/> </td> </tr> </table> </div> </body> </html>
2、结果如下
(1)选中所有的
依次弹出“篮球、足球和排球”
(2)选中部分
依次弹出相应的值
(3)全不选
不弹窗口
相关文章推荐
- jquery水平滑动tab选项卡
- jQuery插件收集
- jquery入门简介
- mvc3 jquery post 复杂json
- jQuery easing.js 效果详解
- 29个非常流行的jQuery提示信息插件
- jquery
- JQuery获取元素宽度.width()与.css(‘width’)两个函数的区别
- JQuery选择器
- 高效jQuery
- 解决jquery mobile的header和footer在点击屏幕的时候消失的办法
- jQuery Mobile 表单基础
- jquery 相册展示,带点击,带小图展示
- jQuery学习笔记—— .html(),.text()和.val()的使用和区别
- AJAX_jQuery框架,三种无刷新方法
- 用jQuery获取table中行id和td值
- jQuery 的 live() 方法对 hover 事件的处理
- jQuery 的 live() 方法对 hover 事件的处理
- jQuery 的 live() 方法对 hover 事件的处理
- jQuery 的 live() 方法对 hover 事件的处理