日期:2014-05-17  浏览次数:21331 次

若干个<input type="button" id="1"/>后天怎么获取点击的那个按钮的值!
新手请教:
前台动态生成若干个<input type="button" id="1"/>后天怎么获取点击的那个按钮的值!(前台的<input type="button" id="1"/>也是在后台动态生成的)


------解决方案--------------------
楼主是要用ajax?
我假设楼主是要将按钮的值发送到后台,然后后台会返回一坨数据
JScript code

$(document).ready( function () {
    $("#1").click( function () { //当id为1的button按下时 执行function
      $.ajax({
        type: "post" //提交方法, 自选
        url: "some_background_handler", //向指定url传递参数
        data: {
          value: $(this).val() //取得value
        },
        dataType: "text" //返回数据格式 还可以选择“script” “html”等等
      })
    });
  });