如何将这些事件更改为.live()事件处理程序?
我以为我可以只更改$(document).ready(function()... to .... $(document).live(function()以及.keydown和.data到.live但我不能似乎让它工作......请帮助.
$(document).ready(function(){
$('#number').bind('keyup change focus', function(){
var field = this;
timer = setTimeout(function(){runSearch(field);}, 444);});
$('#number').keydown(function(){clearTimeout(timer);});
//url selection by specifics
$('#phone_book tr').data('bgcolor', '#aaf').hover(function(){
var $this = $(this);
var newBgc = $(this).data('bgcolor');
$(this).data('bgcolor', $(this).css('background-color')).css('background-color', newBgc);
});
//url selection by specifics
$("#phone_book tr").click(function(){
var id = $(this).children().first().html();
var type = $(this).parents('table').siblings('div.module_header').html().toLowerCase();
Run Code Online (Sandbox Code Playgroud)
更改
.bind(...
Run Code Online (Sandbox Code Playgroud)
至
.on(...
Run Code Online (Sandbox Code Playgroud)
.live()实际上已弃用.
对于像.keyup(),. keydown()这样的人,将那些改为.on('keydown'......等.
| 归档时间: |
|
| 查看次数: |
106 次 |
| 最近记录: |