javascript - Displaying element content as title for tooltip in Bootstrap -
i want show tooltip on several links without coding each "title" atribute. using id atribute specify content from.
this have on head:
<script> $(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip({html : true}); }); </script> then each link on html body
<a href="#eumed"; data-toggle="tooltip" title="#eumed" data-html="true">(eumed, 2011)</a> and want following text show on tooltip text:
<p id="eumed">eumed. (2011). la polĂtica comercial estratĂ©gica. recuperado de: <a href="http://www.eumed.net/cursecon/libreria/2004/fs/comestra.htm">http://www.eumed.net/cursecon/libreria/2004/fs/comestra.htm</a></p> i know can initialize each tooltip javascript or write each title accordingly point here simplify it.
here example (hover number on article see tooltip/popover behavior)
$(document).ready(function(){ $('[data-toggle="tooltip"]').each(function(){ var url=$(this).prop('href'); $(this).tooltip({ html:true, title: $(url.substr(url.lastindexof('#'))).html() }) }) }); /* tooltip */ .tooltip > .tooltip-inner { padding: 15px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <div class="container"> <h3>tooltip example</h3> <a href="#eumed" data-toggle="tooltip" data-placement="right">(eumed, 2011)</a><br/><br/><br/><br/> <p id="eumed">eumed. (2011). la polutica comercial estratugica. recuperado de: <a href="http://www.eumed.net/cursecon/libreria/2004/fs/comestra.htm">comestra</a></p> </div>
Comments
Post a Comment