jQuery 在文本框中传递输入时调用函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17894972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 20:10:00 来源:igfitidea点击:
Call function on pass input in textbox
提问by S. S. Rawat
I want to call the function in every input pass on textbox, but it does not work., either when i enter any input or remove input..it is work like intellisense textbox
我想在文本框的每个输入传递中调用该函数,但它不起作用。
<input id="btnSearch" type="text" value="Search" class="search_btn" onchange="Call()" />
<script>
function Call()
{
alert("Me");
}
</script>
回答by Arghya C
Probably what you want to do is -
可能你想做的是——
<input id="txt_Search" type="text" onchange="Call()" />
<script>
function Call()
{
alert("Search suggestions can come here!!");
}
</script>
Or, using simple jQuery
或者,使用简单的 jQuery
$("#txt_Search").keyup( function() {
var searchQuery = $("#txt_Search").val();
alert("Seacrh suggestion satrting with - " + searchQuery);
});