2010-07-10 23 views

回答

1

没有测试此代码,但我想你应该使用这样的事情...

var divSelected = null; 
    $(document).ready(function(){ 
    $("div").click(
     function(){ 
     divSelected = caller.id; 
     alert(test.val()); 
    } 
); 
    $('#DIV').keypress(function(e){ 
     if(e.which == 46 && divSelected){ // 46 is the keycode for the delete key... 
      // do what you want... 
     } 
    }); 
}); 
0

加里斯末郎是接近的,但我认为它应该是:

$(function(){ 
    var divSelected = null; 
    $('div').click(
     function(){ 
     divSelected = this; 
    }); 
    $('div').keypress(function(e){ 
     if(e.which == 46 && this == divSelected){ 
     alert('Delete me!'); 
     } 
    }); 
}); 

而且完全未经测试;)

相关问题