这个小项目已经做了很久了,牛牛们帮解决一下吧~~~~~
$(window).keyup(function (){
var eve = window.event || e;var imgs = $("#game").children();
if(flag){
for( var i = 0 ; i<imgs.length ; i++ ){
var img = imgs[i];
var code = eve.KeyCode;
if(img.nodeType == 1){
var imgSrc = img.src.split("/");
var name = imgSrc[imgSrc.length-1].split(".")[0];
if(name == chars[code-65]){
img.remove();
score+=10;
$(".score").html(score);
ok.play(); //播放声音
}
//return ;
}
}
}
});