在Bootstrap 3中更改工具提示的标题

时间:2015-03-08 14:21:07

标签: jquery html twitter-bootstrap-3 twitter-bootstrap-tooltip

我有一个glyphicon,表示我页面上的书签的“拖动到工具栏”图标。它还有一个工具提示。它工作得很好但有问题;

当我悬停glyphicon时,我想将“将其拖到工具栏”文本显示为工具提示。但是当我这样做时,将图标拖到我的工具栏后,它的名称也会“拖到工具栏上”,因为浏览器会像tooltip()函数那样读取title属性。我已经尝试更改锚点和跨度的标题属性但是没有用。

如何更改tooltip()函数以使其读取另一个属性作为我的工具提示文本,以便我可以将title属性更改为我的网站名称。

这是我的代码:

<a href="javascript:void(location.href='http://example.com/create.php?url='+encodeURIComponent(location.href))" title="example.com" onclick="return false">
    <span class="bookmarklet glyphicon glyphicon-link hidden-xs hidden-sm" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="✚ example.com" tooltip-text="drag this to your toolbar"></span>
</a>

以及

<script>

$(document).ready(function(){
    $(".bookmarklet").tooltip(); 

}); 
</script>

1 个答案:

答案 0 :(得分:-1)

试试这个:

$(document).ready(function(){
    $(".bookmarklet").tooltip(
    title: function(){
          return $(this).attr('tooltip-text');
           }) 
}); 
相关问题