Enabling and disabling tooltips
We can make use of the enable
or disable
methods to programmatically enable or disable specific tooltips. This will effectively switch on any tooltips that were initially disabled or disable those that are currently active. Let's make use of the enable and disable methods to switch on or off a tooltip, which we will configure to be disabled when the page loads in the browser.
Add the following new <button>
elements directly after the existing markup for the Tooltip widget in tooltip10.html
:
<label for="input">Please enter some text:</label> <input type="text" id="tooltip2" title="I am a tooltip!"> <p> <button id="turnon">Enable Tooltip 1</button> <button id="turnoff">Disable Tooltip 1</button> <p> </body>
Next, change the final <script>
element so that it appears as follows:
<script> $(document).ready(function($){ $("#tooltip").tooltip({ disabled:...