Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bootstrap 4 dynamic tooltip with custom class

I create a dynamic tootltip on target element in the following way :

var dynamicTooltip = new bootstrap.Tooltip($(targetElement));

Everything work just fine, but i would like to add to the generated tooltip a custom class.
Is not clear to me how can i target to the html generated by bootstrap with the previous instruction (or better which bootstrap API should i use to attach a class).
I see that bootstrap tooltip have a class named "tooltip" but i can’t use that class to find my newly generated element eg :

$(".tooltip")

In fact i am afraid that the code above will find also already existing tooltip, and i want target only the newly generated one.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How can i achieve that?

>Solution :

From bootstrap docs:

Here

You can use the template option to give complex HTML structure, or just the customClass option to add custom classes:

var dynamicTooltip = new bootstrap.Tooltip($(targetElement), {
    customClass: 'myCustomClass'
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading