gpt4 book ai didi

jquery - 如何在 jquery 或 javascript 中获取动态创建的文本框值

转载 作者:行者123 更新时间:2023-12-01 07:49:51 25 4
gpt4 key购买 nike

 var max_fields = 9;
var $setting = $("#settingA");
//var $maincontent = $("#mainContent");

// Add html controls
for (var i = 1; i < max_fields; i++) {
var checkedElements = [];
$setting.append("<span style='margin:10px; line-height:2;'><label style='margin-right:10px;'>Channel " + i + "</label><input type='text' name='product_" + i + "' id='product_" + i + "'/></span>");
checkedElements.push($('input[name="product_' + i + '"]').val());
}

最佳答案

在 HTML 中:-

<input type='text' class='product' name='product_" + i + "' id='product_" + i + "'/>

在 jQuery 中:-

 $('.product').each(function() {
var product = $(this).val();
alert(product);
});

关于jquery - 如何在 jquery 或 javascript 中获取动态创建的文本框值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31308116/

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