xzzz 提出了问题 · 2020-01-20
代码如下:
`$('.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
设置的,点击后报错信息如下:
![7P353B6$VJB{CRD0P{%CM96.png 7P353B6$VJB{CRD0P{%CM96.png]()
请问如何获取当前弹窗中input
的value
值?
换成$('#' + id).val()
后不报错了,但是找不到值undefined
![NC61{YHQcode$/codeYIA%H}]R[L[S.png NC61{YHQcode$/codeYIA%H}]R[L[S.png]()
代码如下:`$('.caozuo').click(function () { {代码...} })`因为按钮是遍历上去的,所以id是根据code设置的,点击后报错信息如下: 请问如何获取当前弹窗中input的value值? 换成$('#' + id).val()后不报错了,但是找不到值undefined