Adding custom class to tooltip

后端 未结 8 973
一生所求
一生所求 2021-02-05 02:04

I want to style(css) some bootstrap-tooltip.js tooltips, without affecting all the tooltips. I have tried many different solutions but i allways end up adding a class to the ele

8条回答
  •  盖世英雄少女心
    2021-02-05 02:39

    The method I use is to attach a class directly to the element via JQuery (works in Bootstrap 3). It's a little trickier, because you need to find the hidden, auto-generated element via the parent's data attribute.

    $('#[id$=amount]')
      .tooltip()
        .data('bs.tooltip')
          .tip()
          .addClass('custom-tooltip-class');
    

    I prefer this to overriding the template, because it's much more concise and less verbose than all that extra HTML.

提交回复
热议问题