Bootstrap 5.2 update Tooltip Title with Javascript is not working
See original GitHub issuePrerequisites
- I have searched for duplicate or closed issues
- I have validated any HTML to avoid common problems
- I have read the contributing guidelines
Describe the issue
Hello Update Tooltip Title with Javascript was working fine in version v5.1.3 of bootstrap.bundle.js, but now it is not working using version v5.2.0-beta1 of the same file.
This is the code I use
$(function () {
$('[data-toggle="tooltip"]').tooltip()
document.getElementById('tt').setAttribute('data-bs-original-title', 'New Tooltip Title');
})
stackoverflow: Bootstrap 5 update Tooltip Title with Javascript
Reduced test cases
with version 5.0.0 https://codepen.io/moshair/pen/ExQweey
with version 5.2 beta https://codepen.io/moshair/pen/zYREJmq
What operating system(s) are you seeing the problem on?
Windows
What browser(s) are you seeing the problem on?
Firefox
What version of Bootstrap are you using?
v5.2.0-beta1
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
Bootstrap 5 update Tooltip Title with Javascript - Stack Overflow
You can update the tooltip title by changing the data-bs-original-title attribute.
Read more >Tooltips · Bootstrap v5.2
Documentation and examples for adding custom Bootstrap tooltips with CSS and JavaScript using CSS3 for animations and data-bs-attributes for local title storage ...
Read more >How to Create Tooltips with Bootstrap 5 - Tutorial Republic
Tooltips can be enabled via JavaScript — just call the tooltip() Bootstrap method with the id , class or any CSS selector of...
Read more >Tooltips not showing up with latest version of Bootstrap
In the 4.x version, Bootstrap Tooltips were not enabled by default. You had to manually add the javascript. But as of BSS 5.x,...
Read more >Bootstrap 5 Tooltip - W3Schools
To create a tooltip, add the data-bs-toggle="tooltip" attribute to an element. ... Note: Tooltips must be initialized with JavaScript to work. The following...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@moshair I see what you are trying to do. I downloaded the source code and unfortunately it seems that they dropped support for that attribute. Reading the source code also indicates that this attribute was never documented and essentially was never meant to be used. https://github.com/twbs/bootstrap/blob/v5.1.3/js/src/tooltip.js#L237
Now you should be able to use the function
setContent
on tooltips like documented here. https://getbootstrap.com/docs/5.2/components/tooltips/#methodsYour new way of changing it is now the following:
and your HTML element
What is your goal? Keep the old title or just overwrite it?
dublicate to: https://github.com/twbs/bootstrap/issues/32944
I couldn’t find any line in the documentation talking about the
data-bs-original-title
attribute. The problem you mentioned occured in bootstrap 4 according to the stackoverflow link you linked. The title attribut is now responsible for displaying the tooltip content. If you first set the title and then initialize the tooltip, everything is working.This was a solution mentioned in your stackoverflow link: https://stackoverflow.com/a/65863062/10192487 However it should be possible to use
data-bs-title
because the options are saying that you can use the prefixdata-bs-
to adjust the options which working since 5.1 or 5.2. [doc ref]Your examples seem to be a bit odd.
Your 5.0 example includes beta source Links which might not represent a stable behaviour. Since 5.0 Tooltips are getting initialized like this
new bootstrap.Tooltip(jQuery('[data-toggle="tooltip"]'));
[doc ref]Bootstrap should according to documentation only initialize with jQuery by searching for the
jQuery
Object on window instead of$
. [doc ref]Both of your button markups include the
data-placement
attribute which should bedata-bs-placement
in 5.0. [doc ref]