Popover message in a div

1

Good morning. I have a div that when clicked opens a page. So far so good and it's working.

Now as I do so that when the user hover over this DIV, a popover with the message "To edit click here" appears.

My code looks like this:

<div class="card-body card-padding container editar">
     meu conteudo xxxxxxxxxxxx
</div>

When I click on this div, I have a javascript that opens the page I want:

<script type="text/javascript">
        $(document).ready(function () {
       document.querySelector('.editar').onclick = function(){
    window.location = 'http://minhapagina.com';
}
        });
</script> 

I'm sorry for the silly question ... how do I do when to move the mouse, popover appears?

Thank you

    
asked by anonymous 25.05.2018 / 14:27

1 answer

1

As you put in the question tag Bootstrao 3 I will consider that you are using it.

Boostrap 3 has this component natively. You do not have to add anything else to make it work. Here's the documentation. link

Here is a handy example used in the documentation. Within title=" " of element you put your text.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<style>
    body {
        margin: 40px;
    }
div.btn {
    background-color: red !important;
    background-image: none;
    color: #fff;
}
</style>
</head>
<body>
    
    <button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="left" title="Tooltip on left">Tooltip on left</button>

<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Tooltip on top">Tooltip on top</button>

<div class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="hover na div">isso é uma div</div>

<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="right" title="Tooltip on right">Tooltip on right</button>


    
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script>
    $(function () {
        $('[data-toggle="tooltip"]').tooltip()
    })
    </script>
</body>
</html>

Note that you only need to "start" popover with this script and use the classes of the documentation.

$(function () {
    $('[data-toggle="tooltip"]').tooltip()
})
    
25.05.2018 / 14:34