ajbeaven
ajbeaven

Reputation: 9562

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

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?

Upvotes: 18

Views: 19895

Answers (3)

polyp
polyp

Reputation: 48

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

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

Upvotes: 2

Ben Cox
Ben Cox

Reputation: 1483

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

Upvotes: 29

ajbeaven
ajbeaven

Reputation: 9562

Ahh, found the answer:

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

Upvotes: 19

Related Questions