I'm using jquery 1.9 and jquery UI 1.10
I want to be able to get the tab ID when clicking on a tab. For example if I clicked tab named "Second" I want to get "tabs-2" response.
I've done the below code so far:
<script type="text/javascript"> $(function () { $("#tabs").tabs({ beforeActivate: function (event, ui) { alert(/* the id of the tab (div) being activated */); } }); }); </script> <div id="tabs"> <ul> <li><a href="#tabs-1">First</a></li> <li><a href="#tabs-2">Second</a></li> </ul> <div id="tabs-1"> <p>abcde</p> </div> <div id="tabs-2"> <p>fghi</p> </div> </div>
Tested and working with JQueryUI 1.10, how to get the ID of the tab as it is selected:
$("#tabs").tabs({ beforeActivate: function (event, ui) { alert(ui.newPanel.attr('id')); } });
2.1m questions
2.1m answers
60 comments
57.0k users