How to change placement of Twitter-Bootstrap toolt

2019-02-08 04:54发布

I want to change placement of a Bootstrap tooltip on a text box after it has been already initialized:

// these don't work
$('#myTextbox').tooltip({ placement: 'left' });
$('#myTextbox').tooltip('options', 'placement', 'right' });

Is there any way to do it? If so, what am I doing wrong?

3条回答
贪生不怕死
2楼-- · 2019-02-08 05:29

Ahh, found the answer:

$('#myTextbox').data('tooltip').options.placement = 'right';
查看更多
欢心
3楼-- · 2019-02-08 05:34

In Bootstrap 2.x, the answer is as ajbeaven states:

$('#myTextbox').data('tooltip').options.placement = 'right';

However, from Bootstrap 3, all Bootstrap data is namespaced with bs:

$('#myTextbox').data('bs.tooltip').options.placement = 'right';
查看更多
萌系小妹纸
4楼-- · 2019-02-08 05:45

Adding to Ben Cox's response, in Bootstrap 4 use:

$('#myTextbox').data('bs.tooltip').config.placement = 'right';
查看更多
登录 后发表回答