如何使用JQuery调用Javascript函数?

问题描述:

我,我想这个JavaScript函数通过一个jquery脚本调用:如何使用JQuery调用Javascript函数?

document.location.href = 'http://cse.google.com/cse?cx=009002930969338329916:kta6o_isob0&q=' + escape(document.getElementById('search-box').value) 

我还使用加字符作为编码的程序,我也使用Chromebook。

+0

使用'on'取代'live',让我知道如何去 – Claudiordgz

+0

是否有'#submit'任何点击事件? – Azim

+0

不工作,也许铬不喜欢JQuery? – Kallus

live for event handling was removed in jQuery 1.9, you are using 1.11.,尝试用on代替。 Chrome工作正常。

这里是一个小提琴https://jsfiddle.net/atg5m6ym/359/

还要检查你的KEYUP被返回13你的需要。

$(document).ready(function() { 
    $('#search-box').on("keyup", function(event) { 
    $('#submit').click(); 
}); 
}); 

如果你在keyup中输入任何东西,你会看到hello world。

if(event.keyCode == '13')会为enterreturn关键