How to change placement of Twitter-Bootstrap tooltip placement after initialization?

前提是你 提交于 2019-12-18 14:14:42

问题


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?


回答1:


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';



回答2:


Ahh, found the answer:

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



回答3:


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

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


来源:https://stackoverflow.com/questions/10181847/how-to-change-placement-of-twitter-bootstrap-tooltip-placement-after-initializat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!