代码如下:
`$('.caozuo').click(function () {
var name = $(this).data("name"),
gailu = $(this).data("gailu"),
code = $(this).data("code"),
id = 'input' + code
layer.open({
title: name + '概率',
content: '<input type="number" id="' + id + '" value="' + gailu + '" style="width:100%;"/>',
btn: ['确定', '取消'],
yes: function (index) {
layer.close(index);
var val = $('"#' + id + '"').val()
//var ss = $(this).parents(".layui-m-layerchild").find("input").val()
console.log(val)
}
});
})`
因为按钮是遍历上去的,所以id
是根据code
设置的,点击后报错信息如下:
请问如何获取当前弹窗中input
的value
值?
换成$('#' + id).val()
后不报错了,但是找不到值undefined
引号用多了吧