0
。对下面这个链接:过渡到更新的jQuery库
jQuery 1.9 .live() is not a function
我觉得我有什么是正确的,但它不执行。我是从jQuery的1.5
升级到1.9
,我把它换成.live()
与.on()
但我的代码仍然未正确执行。有什么我做错了吗?
是:
$('a[rel != "noAJAX"]').live('click', function(event){
现在:
$('a[rel != "noAJAX"]').on('click', 'a', function){
全码:
$(function(){
// Link handling.
$('a[rel != "noAJAX"]').on('click', 'a', function){
if ($(this).attr('name') != ""){
var currentDiv = $(this).attr('name');
}else{
var currentDiv = divID;
}
$(currentDiv).html(loadingHTML);
$(currentDiv).load($(this).attr('href'));
event.preventDefault();
});
$('form[rel != "noAJAX"]').on('submit', function(event){
if ($(this).attr('name') != ""){
var currentDiv = $(this).attr('name');
}else{
var currentDiv = divID;
}
$(currentDiv).html(loadingHTML);
$.post($(this).attr('action'), $(this).serialize(), function(html){
$(currentDiv).html(html);
});
return false;
});
});
你做什么,我在你的最后一个问题的意见建议? – j08691 2014-10-17 20:58:59
@MelanciaUK这不是“活”虽然。 – user2864740 2014-10-17 21:01:53