Here is my HTML:
<div id="disclaimer">After 30 Days you'll have the option to keep your account for $15 per month -no contract required-or revert to a single page free account.*</div>
JavaScript:
$('#disclaimer').popover({
trigger: 'hover',
html: true,
placement: 'right',
content: 'hello world'
});
When I hover over the element, nothing happens.. no JavaScript errors or anything, not sure whats wrong
js . Popovers are opt-in for performance reasons, so you must initialize them yourself. Zero-length title and content values will never show a popover. Specify container: 'body' to avoid rendering problems in more complex components (like our input groups, button groups, etc).
To create a popover, add the data-toggle="popover" attribute to an element. Note: Popovers must be initialized with jQuery: select the specified element and call the popover() method.
To make the image on hover in popover just insert an image as an HTML element to the data-mdb-content and set the data-mdb-html to true .
Many of our components require the use of JavaScript to function. Specifically, they require our own JavaScript plugins and Popper.
Using your exact code, all I had to do to get it to work was wrap it in a function call and put the script below the div tag. If you placed your jQuery in an onload function it would work just as well. Good luck.
Use this:
<div id="disclaimer" >After 30 Days you'll have the option to keep your account for $15 per month -no contract required-or revert to a single page free account.*</div>
<script>
$(function ()
{
$('#disclaimer').popover(
{
trigger: 'hover',
html: true,
placement: 'right',
content: 'hello world'
});
});
</script>
OR
$(document).ready(function()
{
$('#disclaimer').popover(
{
trigger: 'hover',
html: true,
placement: 'right',
content: 'hello world'
});
});
i had been looking for over a day as to why my popover wasn't working after getting autodisabled due to events happening on my page (a complicated app, something that gets enabled/disabled depending on the state of what is going on) and the key was to NOT have it the document ready but to have it out in a function because it gets enabled after document initialization on a button click.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With