프로그램/jQuery

jQuery Search 구현

mulderu 2010. 6. 27. 17:01

초간단... Search 함수 구현

$(document).ready(function() {

//apply fancybox to each of the elements, passing in the correct size

$('#search-go').click(function() {

var searchTerm = $('#search-input').val();

if (searchTerm.length > 0)

window.location.href = '/us/search?q=' + escape(searchTerm);

return false;

});

$('#search-input').bind('keypress', function(e) {

if (e.keyCode == 13) {

var searchTerm = $('#search-input').val();

if (searchTerm.length > 0)

window.location.href = '/us/search?q=' + escape(searchTerm);

return false;

}

});

});