简体   繁体   中英

Show tooltip using Javascript or jQuery on Span Tag

I want to show tool-tip on span tag.

<span class="test" href="#" data-toggle="tooltip" data-placement="top" title="Hooray!">*</span>

The jQuery Code That I have done

<script>
 $(document).ready(function(){
 $('[data-toggle="tooltip"]').tooltip();   
 });
</script>

But this is not running. Any Help appreciated in advance.

Make sure you have loaded jquery and jquery-ui scripts:

 $(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip(); }); 
 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <span class="test" href="#" data-toggle="tooltip" data-placement="top" title="Hooray!">* Hover</span> 

Remeber to inject all the dependency / packages needed for your application.

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js""></script>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM