简体   繁体   English

如何显示输入框的更新值?

[英]How do I display updated value of input box?

I have an input and I set its value with jQuery 我有一个输入,我用jQuery设置了它的值

$('#' + inputId).val(function() {
    alert("SETTING VAL TO "+ myValue);
    return myValue;
});

Low and behold this sets the value, as verified in the console. 低,请注意,这将设置值,如在控制台中验证的那样。 However the displayed value in the input text area does not change. 但是,输入文本区域中的显示值不会改变。 How do I do that? 我怎么做?

It turned out I had two elements with the same id. 原来,我有两个具有相同ID的元素。 Weird thing is the chrome element inspector showed the correct value attribute for the input, but the text did not change, presumably for this reason. 奇怪的是chrome元素检查器显示了输入的正确value属性,但文本没有更改,大概是因为这个原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM