Enabling and disabling tabs
We can make use of the enable
or disable
methods to programmatically enable or disable specific tabs. This will effectively switch on any tabs that were initially disabled or disable those that are currently active.
Let's use the enable
method to switch on a tab, which we disabled by default in an earlier example. Add the following new <button>
elements directly after the existing markup for the tabs widget in tabs5.html
:
<button type="button" id="enable">Enable</button> <button type="button" id="disable">Disable</button>
Next, change the final <script>
element so that it appears as follows:
<script> $(document).ready(function($){ $("#myTabs").tabs({ disabled: [1] }); $("#enable").click(function() { $("#myTabs").tabs("enable", 1); }); $("#disable").click(function() { $("#myTabs").tabs("disable", 1); }); }); </script>
Save the changed file as tabs11.html
. On the page, we've added two new <button...