jquery的live方法,firebug为什么总是提示不是一个function

代码:

$('.banner-circle li').live('click', function() {
		var index = $('.banner-circle li').index(this);
		$banner_ul.animate({
			left : -v_width * index
		}, 'slow');
		page = index + 1;
		cirMove();
	});

最后才明白是jqueryde 版本问题,(是jquery-1.9.1.min.js)。jquery1.4使用.live(),1.7以后开始使用.on()。  

$('.banner-circle li').live('click', function() {
		var index = $('.banner-circle li').index(this);
		$banner_ul.animate({
			left : -v_width * index
		}, 'slow');
		page = index + 1;
		cirMove();
	});
$('.banner-circle li').on('click', function() {
		var index = $('.banner-circle li').index(this);
		$banner_ul.animate({
			left : -v_width * index
		}, 'slow');
		page = index + 1;
		cirMove();
	});

jquery中的on和live(以及delegate)效果是不同的 
live以及delegate对于以后创建的dom节点依然有效,on就指定到当前节点了 
当然,使用live和delegate的选择器有很大特点,就是它支持新增加的dom节点,也就是可能是多个,如果使用$('#id'),就看不出有代理方式有什么方式了

你可能感兴趣的:(jquery,on,live)