简体   繁体   English

更改提交到onkeyup事件

[英]change submit in to onkeyup event

I have found a nice script at Google Powered Site Search I'm trying to change the jquery with no luck so far. 我在Google Powered Site Search中找到了一个不错的脚本,到目前为止,我一直在尝试更改jquery,但没有成功。

I changed this code: 我更改了这段代码:

$(‘#searchForm’).submit(function(){
googleSearch();
return false;
});

In to this: 在此:

$(‘#s’).keyup(function() {
$(‘#searchForm’).submit(function(){
googleSearch();
return false;
});

But it doesn't work…Can someone tell me way that is.?? 但这是行不通的……有人可以告诉我那是吗??

I also tried this: 我也试过这个:

$(“input”).keyup(function () {
googleSearch();
return false;
});

Also didn't work. 也没有用。 It's just jquery so it should work.. 这只是jQuery,所以它应该可以工作。

Thank's 谢谢

Do the original code is working? 原始代码是否有效? Also the modified code have missing end braces. 修改后的代码也缺少尾括号。

Check this: 检查一下:

    $('#s').keyup(function() {
        $('#searchForm').submit(function(){
        googleSearch();
        return false;
        });
    });

Try this, it works : 试试这个,它的工作原理:

$("#s").keyup(function(){
     googleSearch();
     return false;         
 })

See Eg 例如

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

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