[英]how to get textbox value from ontextchanged event using jquery/javascript
How to get textbox value from their textchanged event using jquery/javascript. 如何使用jquery / javascript从其textchanged事件获取文本框值。 I tried many things but didnt work. 我尝试了很多事情,但没有成功。 The last is I try, Here is the following code 最后是我尝试的,这是下面的代码
@for (int i = 0; i < Model.MaterialRecordRowCount; i++)
{
<div class="form-group row">
<div class="col-sm-3">
<input type="text" id="Material_PartNo@(i)" name="Material_PartNo@(i)" data-provide="typeahead" class="typeahead search-query form-control autocomplete" placeholder="PartNo" onclick="ShowData ('$('#Material_PartNo@(i)').val()')" />
</div>
</div>
}
function ShowData(PartNo) {
alert(PartNo);
}
Now when I run this code it shows an error ie Uncaught SyntaxError: Invalid or unexpected token 现在,当我运行此代码时,它显示一个错误,即Uncaught SyntaxError:无效或意外的令牌
I am not getting the right syntax even dont know that this method is right for getting the textbox value by their textchanged event or not. 我没有得到正确的语法,甚至不知道此方法是否适合通过textchanged事件获取文本框值。
Change 更改
onclick="ShowData('$('#Material_PartNo@(i)').val()')"
To 至
onclick="ShowData(this.value)"
however I suspect from the classes you are implementing an autocomplete plugin and need to work within the API of that plugin 但是我怀疑从类中您正在实现自动完成插件,并且需要在该插件的API中工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.