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

jsp在div中嵌入新的button按钮,不能触发
这是嵌入的代码:
$("#infor").remove();  //移除之前的div
document.getElementById("selectInfor").style.display = "";

var html="";
html += "<table class='table_box table_bottom_border' id='newInforList'><tr><th><b>客户编号</b></th><th><b>客户姓名</b></th><th><b>申请资金</b></th><th><b>操作</b></th></tr>";
html += ("<tr><td>" + data["clientid"] + "</td><td>" + data["proposername"] + "</td><td>" + data["applymoney"] + "</td><td>" + "<input type='button' class='getInfor' value='确定'/>" + "</td></tr></table>");
$("#selectInfor").html(html); //将拼装后的代码嵌入到<div>标签内。



这是对按钮的操作

$(".getInfor").click(function(){
$("#clientid").val($(this).parent("td").parent("tr").children("td:eq(0)").text());
$("#proposername").val($(this).parent("td").parent("tr").children("td:eq(1)").text());
$("#OpenDialog").dialog("close");
}); 
HTML JSP

------解决方案--------------------
div设成浮动的了吧  把button给遮盖住了  
------解决方案--------------------
按钮的触发事件紧跟在 生成这个按钮的代码块后面  js不会像CSS一样实时动态渲染DOM 页面加载完后动态添加的DOM元素 要动态绑定事件  必须在动态添加DOM元素的后面跟着声明这个事件 
------解决方案--------------------

 success : function(data) {
                    $("#infor").remove();
                    var html="";
                    html += "<table class='table_box table_bottom_border' id='newInforList'><tr><th><b>客户编号</b></th><th><b>客户姓名</b></th><th><b>申请资金</b></th><th><b>操作</b></th></tr>";
                    html += ("<tr><td>" + data["clientid"] + "</td><td>" + data["proposername"] + "</td><td>" + data["applymoney"] + "</td><td>" + "<input type='button' class=\"getInfor\" id='newButton' value='确定'/>" + "</td></tr></table>");
                    $("#selectInfor").html(html); //将拼装后的代码嵌入到<div>标签内。
              
 $(".getInfor").click(function(){
            $("#clientid").val($(this).parent("td").parent("tr").children("td:eq(0)").text());
            $("#proposername").val($(this).parent("td").parent("tr").children("td:eq(1)").text());
            $("#OpenDialog").dialog("close");
        });
  },

把绑定事件放到
myeclipse如何取消debug