我这里有一些代码:jQuery的崩溃对.live( “KEYUP”)
$(document).ready(function() {
$("#querybox").live("keyup", function(e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code == 13) {
$("#querybox").blur();
}
else {
search(document.getElementById('querybox').value);
}
/*if (document.getElementById('querybox').value == "") {
$("center").removeHighlight();
}*/
});
});
检测为keyUp并用它来搜索一些东西。问题是:当#querybox后退到空的位置时,整个页面崩溃,我得到“Awwww,Snap!”来自Google Chrome的消息。
我正在使用jQuery v1.7.2
Thx 100万!
编辑
我还要指出的是,搜索()函数在体内凸显文字(注意注释部分)。我现在用的是highlight插件...
搜索FN:
function search(query) {
$("center").removeHighlight();
$(".paragraph").highlight(query);
$(".highlight").each(function (index) {
$(this).attr("id", "tmpforgoToByClassScrollhighlight" + index);
});
}
什么是'search()'?你从Chrome开发者工具中发现了什么? – Pointy 2012-07-12 13:20:59
http://liveisdeprecated.com/ – Adi 2012-07-12 13:21:09
对我来说很好:http://jsfiddle.net/johnkoer/zmYpa/4/ – 2012-07-12 13:23:07