gpt4 book ai didi

javascript - 如何 "get"dijit.layout.tabcontainer 中 "clicked"选项卡的 ID?

转载 作者:行者123 更新时间:2023-11-30 07:11:33 25 4
gpt4 key购买 nike

我一直没能为此找到明确定义的解决方案。大多数是不完整的片段。

这是一个简单的例子。请参阅 doSomething() 评论:

<head>
<style type="text/css">
body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
</style>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.ContentPane");

function doSomething() {
//Put code in here that identifies the clicked tab and displays it's id in the below alert
alert("Hello World!");
}

</script>

</head>

<body class=" claro ">
<div id="mainTab" dojoType="dijit.layout.TabContainer" style="width: 400px; height: 100px;" onClick="doSomething();">
<div id="tab1" dojoType="dijit.layout.ContentPane" title="My first tab" selected="true">
Lorem ipsum and all around...
</div>
<div id="tab2" dojoType="dijit.layout.ContentPane" title="My second tab">
Lorem ipsum and all around - second...
</div>
<div id="tab3" dojoType="dijit.layout.ContentPane" title="My last tab">
Lorem ipsum and all around - last...
</div>
</div>
</body>

最佳答案

我相信 dijit.byId('mainTab').selectedChildWidget 应该为您提供对所选选项卡(例如您的一个 ContentPanes)中的小部件的引用。

http://www.dojotoolkit.org/api/dijit/layout/TabContainer.html#selectedChildWidget

关于javascript - 如何 "get"dijit.layout.tabcontainer 中 "clicked"选项卡的 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3409572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com