Search code examples
twitter-bootstrap-3tooltip

bootstrap 3 tooltip title function


This is a dumb question I'm sure, but how can I pass a function to the tooltip for the title?

<span id="spanCount" data-toggle="tooltip" data-placement="bottom" title="" class="badge tip" data-original-title="getNames()">26</span>

The tooltip is just displaying the text "getNames()"

function getNames(){
            return 'testing';
        }

Solution

  • try data-title instead of data-original-title

    <span id="spanCount" data-toggle="tooltip" data-placement="bottom" title="" class="badge tip" data-title="getNames()">26</span>
    

    or via JavaScript

    $('#mytooltip').tooltip({title: function(){return 'testing';} })