gpt4 book ai didi

javascript - 隐藏字段值包含[object object]

转载 作者:行者123 更新时间:2023-11-28 19:52:26 24 4
gpt4 key购买 nike

我在 jquery 脚本中设置隐藏字段值,但隐藏字段返回包含 [Object Object] 的值

以下是值;

“[对象对象],2014 年 4 月 22 日”

脚本

          var indx = 0;
var hdfield = $('#hdlstVisitDates');
var lst = $('#lstVisitDates');
var options = $('#lstVisitDates option');
$(options).each(function () {

if (indx = 0) {
hdfield = $(this).val();
indx = 1;
}
else
{ hdfield = hdfield + ',' + $(this).val(); }
});

$('#hdlstVisitDates').val(hdfield);

最佳答案

// initialise hdfield with val()
var hdfield = $('#hdlstVisitDates').val();

否则 hdfield 将是输入元素,字符串连接会将其转换为 [object Object]

关于javascript - 隐藏字段值包含[object object],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23201308/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com