简体   繁体   English

如何在javascript函数中访问输入文本字段的值?

[英]How to access the value of the input text field in javascript function?

The code of the text field is:文本字段的代码是:

<s:iterator value="paramSimple" var="param" status="iteratorStatus">
<tr>
<td>
<input type="text" text_id="<s:property value="#iteratorStatus.index" />" value= "<s:property value=" #param.value.split(':')[1] " />"/>
</td>
</tr>
</s:iterator>

How do i access the value of the text field in JS function?我如何访问JS函数中文本字段的值?

I tried using我尝试使用

$("input[text_id='1']")

but it shows the input element instead of the value但它显示输入元素而不是值

you can access the value of an input by using .value您可以使用.value访问输入的值

something like this像这样的东西

<input type="text" id="input"> 
const input = document.getElementById("input");
console.log(input.value); //console logs the value of the input

console.log($("#input").value); //jquery

but obviously you can target it not only with ids, in this case you want to target it with text_id so just add .value behind it to target the value但显然你不仅可以用 ids 来定位它,在这种情况下你想用text_id来定位它,所以只需在它后面添加.value来定位值

$("input[text_id='1']").value

暂无
暂无

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

相关问题 如何在文本字段输入上执行javascript函数并用新值更新字段 - How can I execute a javascript function on text field input and update the field with new value 如何使用javascript访问文本输入值 - how to access text input value with javascript 在 html 表单 JavaScript 中访问文本输入字段值的最简单方法? - Simplest way to access the value of text input field in html form JavaScript? 如何使用 puppeteer 访问文本输入字段中的当前值 - How to access current value in a text input field with puppeteer Javascript,如何在相同的输入类型文本字段中显示两个值? - Javascript, How to show two value into same input type text field? 如何使用 JavaScript 获取文本输入字段的值? - How do I get the value of text input field using JavaScript? 如何从另一个输入文本字段 Javascript 中输入的值将值设置为输入隐藏字段 - how to set the value to a input hidden field from value entered in another input text field Javascript Javascript-如何在按钮的onClick中访问文本字段的值? - Javascript - How to access the value of a text field in the onClick of a button? 如何将按钮的值传递给输入文本字段,但使用javascript在文本字段中值应消失 - How to pass the value of button to input text field but value should be disappear in text field using javascript 如何从JavaScript中的函数设置多个输入字段的值 - How to set the value of the multiple input field from function in javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM