今天出现了一个非常奇怪的问题,我编写了一个JavaScript代码来从动态生成的输入字段中获取值。它运行正常,没有问题,今天它开始返回默认值,以下是代码:
$(document).on("change", "#myprofile .pf_name", function() {
var field_name = $(this).attr("name"); // this the name of field i get on the input
var field_value = $('input[name=' + field_name + ']').val(); //this is the value i am getting from the that input, working fine recently
// I am wriring new value in input box and then when this onchange event triggers it
//retruns default value that was loaded dynamically with the loop.
//However it should return new written value. It was working fine previously.
console.log("field name: " + field_name + " field value: " + field_value);
});
似乎整个代码中出现阻塞或问题。但是我已经检查了所有代码,但找不到任何可疑代码。
这是另一种尝试:
我通过带有类名的jquery生成输入区域。使用默认值生成后,可以说:测试。现在,当我编写新文本:12345并触发其他按钮上的click事件以获取此输入值时,它返回:测试<默认值
任何帮助将不胜感激。