jQuery 怎么在.fn.xx 里面进行on绑定(IE下)

<script type="text/javascript">
    $(function(){
       $('#maintabs').tabdiv();
    })
</script>
(function($) {
	$.fn.tabdiv = function(){  
		self = this;
		thisId = $(self).attr('id');
		tClass = '.' + thisId;
		tab = '#' + thisId + ' ' + '.tab';
		tabDiv = tClass + ' .tab-div';	
		$(document).on('click',tab,function(){
			$(tab).removeClass('active');
			$(this).addClass('active');
			$(tabDiv).removeClass('active');
			$('#' + $(this).data('tab')).addClass('active');
		});
	};
})(jQuery);

如上面的代码,在非IE的浏览器中,$(document).on('click',tab,function(){ 这个绑定是可以的,但在IE中(测试了789),这个绑定无效,点击了绑定的对象也没有反应。。
应该怎么改?

阅读 5.2k
1 个回答

self 前面加个var

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题