[英]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.