Javascript Can';t绑定单击事件
我调用了函数“add_reg”,但当添加新行时,单击事件不起作用,会发生什么?谢谢Javascript Can';t绑定单击事件,javascript,jquery,events,Javascript,Jquery,Events,我调用了函数“add_reg”,但当添加新行时,单击事件不起作用,会发生什么?谢谢 function add_reg(){ cant_empleados++; if($('#id_zona').val() == 2){ var nuevo_reg = '<div style="clear:both"></div><div id="empleado_' + cant_empleados + '" class="cont_empleado" onmouseov
function add_reg(){
cant_empleados++;
if($('#id_zona').val() == 2){
var nuevo_reg = '<div style="clear:both"></div><div id="empleado_' + cant_empleados + '" class="cont_empleado" onmouseover="this.style.background=\'#F2F2F2\';" onmouseout="this.style.background=\'#FFFFFF\';"><div style="float:left; width:136px; padding-left:15px"><input name="existe_emp' + cant_empleados + '" id="existe_emp' + cant_empleados + '" type="hidden" value="n" /><input name="existe_reg' + cant_empleados + '" id="existe_reg' + cant_empleados + '" type="hidden" value="n" /><input name="cuil' + cant_empleados + '" type="text" id="cuil' + cant_empleados + '" value="" style="width:130px" alt="99-99999999-9" onblur="buscarNombre(this.value, ' + cant_empleados + ');" maxlength="13" tabindex="' + tab++ + '"/></div><div style="float:left; width:256px"><input name="apellido_y_nombre' + cant_empleados + '" type="text" id="apellido_y_nombre' + cant_empleados + '" style="width:250px" maxlength="20" tabindex="' + tab++ + '" value=""/></div><div style="float:left; width:106px"><input name="categoria' + cant_empleados + '" type="text" id="categoria' + cant_empleados + '" value="" style="width:100px" maxlength="7" tabindex="' + tab++ + '"/></div><div style="float:left; width:96px"><input name="retribucion_mensual' + cant_empleados + '" type="text" id="retribucion_mensual' + cant_empleados + '" alt="decimal" style="width:90px" onblur="calcular_porcentaje(' + cant_empleados + ');" tabindex="' + tab++ + '" value="" /></div><div style="float:left; width:auto"><input name="cotizacion_sindical' + cant_empleados + '" type="text" id="cotizacion_sindical' + cant_empleados + '" alt="decimal" value="" style="width:80px; background-color:#F1F1F1" readonly="readonly" /> </div><div style="float:left; width:auto"> <input type="checkbox" name="imputar_sss' + cant_empleados + '" id="imputar_sss' + cant_empleados + '" value="' + cant_empleados + '" checked="checked" /> <input name="sistema_social_solidario' + cant_empleados + '" type="text" id="sistema_social_solidario' + cant_empleados + '" alt="decimal" value="" style="width:55px; background-color:#F1F1F1" readonly="readonly" /> </div><div style="float:left; width:auto"> <input type="checkbox" name="imputar_rpp' + cant_empleados + '" id="imputar_rpp' + cant_empleados + '" value="' + cant_empleados + '" checked="checked" /> <input name="prestaciones_previsionales' + cant_empleados + '" type="text" id="prestaciones_previsionales' + cant_empleados + '" alt="decimal" value="" style="width:55px; background-color:#F1F1F1" readonly="readonly" /> </div><div style="float:left; width:auto"> <a href="javascript:borrar_reg(' + cant_empleados + ')" title="Borrar registro" onclick="return confirm(\'¿Esta seguro de querer borrar este registro?\');"><img src="./images/ic_borrar.gif" alt="Borrar" /></a></div></div>';
}else{
var nuevo_reg = '<div style="clear:both"></div><div id="empleado_' + cant_empleados + '" class="cont_empleado" onmouseover="this.style.background=\'#F2F2F2\';" onmouseout="this.style.background=\'#FFFFFF\';"><div style="float:left; width:136px; padding-left:15px"><input name="existe_emp' + cant_empleados + '" id="existe_emp' + cant_empleados + '" type="hidden" value="n" /><input name="existe_reg' + cant_empleados + '" id="existe_reg' + cant_empleados + '" type="hidden" value="n" /><input name="cuil' + cant_empleados + '" type="text" id="cuil' + cant_empleados + '" value="" style="width:130px" alt="99-99999999-9" onblur="buscarNombre(this.value, ' + cant_empleados + ');" maxlength="13" tabindex="' + tab++ + '"/></div><div style="float:left; width:256px"><input name="apellido_y_nombre' + cant_empleados + '" type="text" id="apellido_y_nombre' + cant_empleados + '" style="width:250px" maxlength="20" tabindex="' + tab++ + '" value=""/></div><div style="float:left; width:106px"><input name="categoria' + cant_empleados + '" type="text" id="categoria' + cant_empleados + '" value="" style="width:100px" maxlength="7" tabindex="' + tab++ + '"/></div><div style="float:left; width:96px"><input name="retribucion_mensual' + cant_empleados + '" type="text" id="retribucion_mensual' + cant_empleados + '" alt="decimal" style="width:90px" onblur="calcular_porcentaje(' + cant_empleados + ');" tabindex="' + tab++ + '" value="" /></div><div style="float:left; width:auto"><input name="cotizacion_sindical' + cant_empleados + '" type="text" id="cotizacion_sindical' + cant_empleados + '" alt="decimal" value="" style="width:80px; background-color:#F1F1F1" readonly="readonly" /> </div><div style="float:left; width:auto"> <input name="sistema_social_solidario' + cant_empleados + '" type="text" id="sistema_social_solidario' + cant_empleados + '" alt="decimal" value="" style="width:80px; background-color:#F1F1F1" readonly="readonly" /> </div><div style="float:left; width:auto"> <input name="prestaciones_previsionales' + cant_empleados + '" type="text" id="prestaciones_previsionales' + cant_empleados + '" alt="decimal" value="" style="width:80px; background-color:#F1F1F1" readonly="readonly" /> </div><div style="float:left; width:auto"> <a href="javascript:borrar_reg(' + cant_empleados + ')" title="Borrar registro" onclick="return confirm(\'¿Esta seguro de querer borrar este registro?\');"><img src="./images/ic_borrar.gif" alt="Borrar" /></a></div></div>';
}
$("#totales").before(nuevo_reg);
$("#empleado_" + cant_empleados).hide();
$("#empleado_" + cant_empleados).fadeIn();
$("#cant_empleados").val(cant_empleados);
$("#cuil" + cant_empleados).setMask();
$("#retribucion_mensual" + cant_empleados).setMask();
try{
setActionImputar('#imputar_sss' + cant_empleados);
setActionImputar('#imputar_rpp' + cant_empleados);
}catch(e){
// no hago nada
}}
function setActionImputar(selector){
$(selector).click(function(){
calcular_porcentaje($(this).val());
});}
函数添加_reg(){
不能使用OS++;
if($('#id_zona').val()==2){
var nuevo_reg='';
}否则{
var nuevo_reg='';
}
美元(“#总计”)。之前(新奥尔良);
$(“#empleado_uu”+cant_uempleados).hide();
$(“#empleado_uuu”+cant_uempleados).fadeIn();
$(“不能雇用”).val(不能雇用);
$(“#cuil”+cant#u empleados).setMask();
$(“#检索量”+无法使用)。设置掩码();
试一试{
设定不可抗力(“#不可抗力”+不可抗力);
setActionImputar(“#imputar_rpp”+不能雇佣);
}捕获(e){
//不,哈戈娜达
}}
函数setActionImputar(选择器){
$(选择器)。单击(函数(){
牙石($(this.val());
});}
您应该使用live bind
function setActionImputar(selector){
$(selector).live('click', function(){
calcular_porcentaje($(this).val());
});
}
你应该使用活结
function setActionImputar(selector){
$(selector).live('click', function(){
calcular_porcentaje($(this).val());
});
}
使用live绑定事件
function setActionImputar(selector){
$(selector).live('click', function(){
calcular_porcentaje($(this).val());
});
}
使用live绑定事件
function setActionImputar(selector){
$(selector).live('click', function(){
calcular_porcentaje($(this).val());
});
}
您是否尝试过在firebug/ie dev tools/其他工具中进行调试?添加_reg的调用在哪里?您是否尝试过在firebug/ie dev tools/其他工具中进行调试?添加_reg的调用在哪里??