getting error : TypeError: $(…).live is not a function
本问题已经有最佳答案,请猛点这里访问。
我正在尝试实施内联编辑,但出现错误:
1 2 3 | TypeError: $(...).live is not a function $('#editbox').live('blur',function(){ |
我的代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | $(document).ready(function(){ $('td.edit').click(function(e){ var $target = $(e.target); if($target.is('#editbox')){ return; } $('.ajax').html($('.ajax input').val()); $('.ajax').removeClass('ajax'); $(this).addClass('ajax'); $(this).html('<input id="editbox" size="10" type="text" value="' + $(this).text() + '">'); $('#editbox').select(); } ); $('td.edit').keydown(function(event){ arr = $(this).attr('class').split("" ); if(event.which == 13) { $.ajax({ type:"POST", url:"supplier/update.php", data:"value="+$('.ajax input').val()+"&rowid="+arr[2]+"&field="+arr[1], success: function(data){ $('.ajax').html($('.ajax input').val()); $('.ajax').removeClass('ajax'); }}); } } ); $('#editbox').live('blur',function(){ $('.ajax').html($('.ajax input').val()); $('.ajax').removeClass('ajax'); }); }); |
html:
听起来您使用的是jquery版本> =
在版本
中将其删除了
对于版本> = 1.9,必须使用
尝试,
1 | $('#staticParent').on('blur' ,'#editbox' ,function(){ |
使用
1 | $('body').on('blur', '#editbox', function(){} |
.live()与.on()
.live()在1.9或版本中贬值
替换为.on()
https://api.jquery.com/on/