ence, doneTyping = function (el) { if (!timeoutReference) return; timeoutReference = null; callback.call(el); }; return this.each(function (i, el) { var $el = $(el); $el.is(':input') && $el.on('keyup keypress', function (e) { if (e.type == 'keyup' && e.keyCode != 8) return; if (timeoutReference) clearTimeout(timeoutReference); timeoutReference = setTimeout(function () { doneTyping(el); }, timeout); }).on('blur', function () { doneTyping(el); }); }); } }); })(jQuery); $('.ecsc-search-input').donetyping(function () { search_key(); }, 500).focus(function () { var search_key = $.trim($('#q').val()); if (search_key != '') { $('.candidate').show(); } }); $('.candidate').mouseleave(function () { $(this).hide(); }); function searchWord(words) { $('#q').val(words); $('#searchForm').submit(); } function search_key() { var search_key = $.trim($('#q').val()); if (search_key != '') { $.ajax({ type: 'post', dataType: 'json', data: {key: search_key}, url: "/Home/Api/searchKey.html", success: function (data) { if (data.status == 1) { var html = ''; $.each(data.result, function (n, value) { html += '
  • ' + value.keywords + '
    约' + value.goods_num + '个商品
  • '; }); html += '
  • 关闭
  • '; $('#search_list').empty().append(html); $('.candidate').show(); } else { $('#search_list').empty(); } } }); } }