<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),这个绑定无效,点击了绑定的对象也没有反应。。
应该怎么改?
self 前面加个var