在HTML表格中插入输入类型按钮 [英] Insert Input type button in HTML Table

查看:421
本文介绍了在HTML表格中插入输入类型按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



美好的一天!

我正在为包含INPUT TYPE ="button"的HTML表创建一个插入行:

Hi,

Good day!

I am creating an insert row to an HTML table that includes an INPUT TYPE="button":

var table = document.getElementById('tblSkill');           
var row = table.insertRow(-1);

var rowCount = table.rows.length - 1;

var cell0 = row.insertCell(0);
var cell1 = row.insertCell(1);
var cell2 = row.insertCell(2);

var skill = document.getElementById('txtSkill').value;
var values = document.getElementById('txtValue').value;            

cell0.innerHTML = skill;
cell1.innerHTML = values;
cell2.innerHTML = "<input type='button' value='edit' size=" + lastId + " title=" + rowCount + " name='btnEdit' class='btnEdits'  />"   





单击按钮edit(class =''btnEdits'')具有jQuery功能:





The button edit(class=''btnEdits'') has a jquery function when clicked:

$(".btnEdits").click(function(){                

var v_param = 0;
var v_value = 1;
var v_id = 2;

var r = this.title;                  
var table = document.getElementById('tblSkill');                       
$("#div_edit").show();   

document.getElementById('txtSkill').value = table.rows[r].cells[v_param].innerHTML;
document.getElementById('txtValue').value = table.rows[r].cells[v_value].innerHTML;
document.getElementById('hiddenID').value = table.rows[r].cells[v_id].innerHTML;
document.getElementById('hiddenRow').value = r;
document.getElementById('hiddenAdd').value = '0';           

});




我的问题是,当我动态添加html按钮时,jQuery函数($(.btnEdits").click)无法触发.

请给我一个建议.预先谢谢您:)




My problem here is that the jQuery function ($(".btnEdits").click) is not firing when i add the html button DYNAMICALLY.

Please kindly give me an advice. Thank you in advance :)

推荐答案

(" ).click( var v_param = 0 ; var v_value = 1 ; var v_id = 2 ; var r = .title; var table = 文档 .getElementById(' tblSkill');
(".btnEdits").click(function(){ var v_param = 0; var v_value = 1; var v_id = 2; var r = this.title; var table = document.getElementById('tblSkill');


(" ).show(); 文档 .getElementById(' txtSkill') .value = table.rows [r] .cells [v_param] .innerHTML; 文档 .getElementById(' txtValue') .value = table.rows [r] .cells [v_value] .innerHTML; 文档 .getElementById(' hiddenID') .value = table.rows [r] .cells [v_id] .innerHTML; 文档 .getElementById(' hiddenRow') .value = r; 文档 .getElementById(' hiddenAdd') .value = ' 0'; });
("#div_edit").show(); document.getElementById('txtSkill').value = table.rows[r].cells[v_param].innerHTML; document.getElementById('txtValue').value = table.rows[r].cells[v_value].innerHTML; document.getElementById('hiddenID').value = table.rows[r].cells[v_id].innerHTML; document.getElementById('hiddenRow').value = r; document.getElementById('hiddenAdd').value = '0'; });




我的问题是,当我动态添加html按钮时,jQuery函数(




My problem here is that the jQuery function (


(.btnEdits").click)无法触发.

请给我一个建议.预先谢谢您:)
(".btnEdits").click) is not firing when i add the html button DYNAMICALLY.

Please kindly give me an advice. Thank you in advance :)


这篇关于在HTML表格中插入输入类型按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆