Calling a function from an event

I’m having trouble with this code:


jQuery(document).ready(function() {
     jQuery('#s').keyup(get_search_results);
});

function get_search_results() {
    alert( 'test' );
}

Nothing is happening. Are events not meant to call functions in this manner?

Well I’ve found that entering an empty first parameter helps:


jQuery( '#s' ).keyup( '',get_search_results) ;

This finally works in a basic html testing environment, but it continues to fail in my Wordpress testing environment. I’ve made sure both environments are using the same version jquery.

Do you have some place where we can see this happening? Link? If there is no link, at the minimum, give us your “wordpess environment” that clearly shows the problem happening :).

Turned out to be an error with the testing, not the code. There was a second text input with the same id on the page. Apparently, Wordpress doesn’t assign unique id’s when adding new search widgets. Both keyup(callback_method) and keyup(‘’, callback_method) work.