+ -
当前位置:首页 → 问答吧 → 初学者问题,如何获取button 本身的value

初学者问题,如何获取button 本身的value

时间:2010-01-08

来源:互联网

复制代码
  1.  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <title>无标题文档</title>
  6. <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
  7. <script type="text/javascript">
  8.  $(document).ready(function(){
  9.  $(":button").click(function(){
  10.   alert($("this.[name=del]").val());
  11.  });
  12.  })
  13.  </script>
  14. </head>
  15. <body>
  16.  <form action="" name="form"  method="post">
  17.   <input type="button" name="del" value="删除" />
  18.   <input type="button" name="on" value="开启" />
  19.   <input type="button" name="off" value="关闭" />
  20.  </form>
  21. </body>
  22. </html>


点击button如何获取各自的value??
初学者  见笑了

作者: yilander   发布时间: 2010-01-08

$(":button").each(function(i){alert($(this).val())});

作者: yake_yk   发布时间: 2010-01-08

相关阅读 更多