Uncaught TypeError: Cannot read property 'attr' of undefined

1、错误描述

Uncaught TypeError: Cannot read property 'attr' of undefined
    at HTMLDivElement.activate (http://127.0.0.1:8020/jqGrid/pages/tab.html:24:29)
    at $.(anonymous function).(anonymous function)._trigger (http://127.0.0.1:8020/jqGrid/js/jquery-ui.js:697:13)
    at complete (http://127.0.0.1:8020/jqGrid/js/jquery-ui.js:15354:9)
    at show (http://127.0.0.1:8020/jqGrid/js/jquery-ui.js:15364:5)
    at $.(anonymous function).(anonymous function)._toggle (http://127.0.0.1:8020/jqGrid/js/jquery-ui.js:15379:4)
    at $.(anonymous function).(anonymous function)._toggle (http://127.0.0.1:8020/jqGrid/js/jquery-ui.js:144:25)
    at $.(anonymous function).(anonymous function)._eventHandler (http://127.0.0.1:8020/jqGrid/js/jquery-ui.js:15341:8)
    at $.(anonymous function).(anonymous function)._eventHandler (http://127.0.0.1:8020/jqGrid/js/jquery-ui.js:144:25)
    at HTMLAnchorElement.handlerProxy (http://127.0.0.1:8020/jqGrid/js/jquery-ui.js:606:7)
    at HTMLAnchorElement.dispatch (http://127.0.0.1:8020/jqGrid/js/jquery-1.11.0.min.js:3:8066)

2、错误原因

$(function(){
     $("#tabs").tabs({
	active:1,
	activate: function(event, ui){
	     var ids = ui.newHeader.attr("id");
	     console.info(ids);
	}
    });
});
      jquery UI中ids获取的方式ui.newHeader.attr("id")是accordion获取id的方式,而不是tabs获取id的方式


3、解决办法

$(function(){
     $("#tabs").tabs({
	active:1,
	activate: function(event, ui){
	     var ids = ui.newPanel.attr("id");
	     console.info(ids);
	}
    });
});
       var ids = ui.newPanel.attr("id");是tabs获取id的方式


你可能感兴趣的:(JQuery,jQuery,UI)