I have a select which has a tooltip applied for each option. I would like to know how to make the tooltip work for the option that is already selected.
$(document).tooltip();
<select> <option value="one" title="Option one">one</option> <option value="two" title="Option two">two</option> <option value="three" title="Option three">three</option> </select>
According to documentation ,
$(document).tooltip();
Working sample: https://jsbin.com/pogudavuxu/edit?html,js,output
Answer: Update select title on change,
$(document).ready(function(){ $("#sel").change(function() { this.title = $(this).val(); }); });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <select title="one" id="sel"> <option value="one" title="Option one">one</option> <option value="two" title="Option two">two</option> <option value="three" title="Option three">three</option> </select>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.