-1

I want to get the ID of the inner DIV using javascript. Please see the fiddle http://jsfiddle.net/5yn2hLv9/8/ . When i click on First Tab/Second Tab.., the id of the tab should be retrieved in the javascript function getInnerDivId() . please suggest.

Below is sample code:

<div dojoType="dijit.layout.TabContainer" style="width: 100%;height: 100px" tabStrip="true" onclick="getInnerDivId()">
    <div dojoType="dijit.layout.ContentPane" class="one" title="First tab" selected="true" id="1" >
        11
    </div>
    <div dojoType="dijit.layout.ContentPane" class="one" title="Second tab" id="2">
        2222
    </div>
    <div dojoType="dijit.layout.ContentPane" class="one" title="Last tab" id="3">
        333333
    </div>
</div>
user4199704
  • 11
  • 1
  • 1
  • 9
  • Have you checked this answer? http://stackoverflow.com/questions/3409572/how-do-i-get-the-id-for-a-clicked-tab-in-a-dijit-layout-tabcontainer – grizzly Nov 21 '14 at 22:07
  • @grizzly - Yes i could not able to get what i need to pass in onClick="doSomething" , the last answer in http://stackoverflow.com/questions/3409572/how-do-i-get-the-id-for-a-clicked-tab-in-a-dijit-layout-tabcontainer , as in javascript doSomething(e) is accepting one value. Please suggest. – user4199704 Nov 21 '14 at 22:15

1 Answers1

1

Just ask your dojo to give you the contents of the selected tab:

Do this in your click handler function:

function getInnerDivId() {
    var value = this.selectedChildWidget.domNode.attributes["id"].value;
    alert("get inner div iD: " + value);
}

See the fiddle here.

grizzly
  • 1,146
  • 12
  • 26
  • Did you want the `id` attribute or the contents of the `
    ` (that 2222 etc.)?
    – grizzly Nov 21 '14 at 22:16
  • 1
    Be sure to remove the `()` from `onclick="getInnerDivId()"` as shown in the fiddle to ensure that `this` is correct in your function. – Hacknightly Nov 21 '14 at 22:21