解决方案:
$("#table").on("click","td",function(){ alert($(this).attr("id")); });
js给
1.解决赋值问题。
在前端使用Js给ASP.NET服务器控件
$("#btnaddbaby").click(function () {
var monitorid = $(this).attr("id");
console.log($(this).attr("id"));
});
ddl 动态添加options
var htmlInfo = "";
//ddlbaby
$.each(obj, function (n, value) {
htmlInfo += " ";
});
$("#ddlbaby").append(htmlInfo);
$(function () {
//获得绑定数据
$.ajax({
type: "POST",
url: "/ajax/BabyHandler.ashx",
dataType: "json",
data: {
act: 'getlist'
},
success: function (e) {
if (e.ResultCode == 1) {
var obj = e.lstBaby;
var htmlInfo = "";
htmlInfo += `
htmlInfo += `
`; });
htmlInfo += `
});
$("#btnaddbaby").click(function () {
var monitorid = $(this).attr("id");
console.log($(this).attr("id"));
$(".showpop").show();
$(".bindbaby").hide();
$(".showbindbabywrap").hide();
$(".addbabywrap").show();
});
$("._monitorempty").click(function () {
var monitorid = $(this).attr("id");
console.log($(this).attr("id"));
$(".showpop").show();
$(".bindbaby").show(); $(".addbabywrap").hide();
$(".showbindbabywrap").hide();
$(".showpop_manitor_name").text(monitorid);
});
$("._monitorbaby").click(function () {
var monitorid = $(this).attr("id");
console.log($(this).attr("id"));
$(".showpop").show();
$(".bindbaby").hide(); $(".addbabywrap").hide();
$(".showbindbabywrap").show();
$(".showpop_manitor_name").text(monitorid);
});
$(".close").click(function () { $(".showpop").hide(); });
});