Kallus
Kallus

Reputation: 1

How do I call a Javascript Function using JQuery?

I i'd like this javascript function to be called by a jquery script:

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

I'm also using Caret as the coding program, I also use a Chromebook.

Upvotes: 0

Views: 42

Answers (1)

Claudiordgz
Claudiordgz

Reputation: 3049

live for event handling was removed in jQuery 1.9, you are using 1.11., Try using on instead. Chrome works fine.

Here is a fiddle https://jsfiddle.net/atg5m6ym/359/

Also check that your keyup is returning the 13 you need.

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

If you input anything in the label on keyup you'll see the hello world.

if(event.keyCode == '13') would be for the enter or return key

Upvotes: 1

Related Questions