Is there any way to make a default browser tooltip appear without placing the text in the title tag and without the tooltip plug-in?

5

I'm asking this because the application is almost ready and used a plugin that uses the title tag. This plugin causes a popup (in this case a confirmation box) to be clicked on the element, with a title bar using the title tag text.

But when using the title tag, this plug-in removes the same from the element, making it impossible for the mouse to appear above the tooltip.

    
asked by anonymous 02.01.2014 / 16:15

3 answers

10

On the Bootstrap page you can read about the data-title property:

  

default title value if title attribute is not present

What it means:

  

The value of the title if the title attribute is not present.

This means that one solution would be to add the data-title attribute to elements that have popover with the same value as the title attribute.

You can do this via javascript before calling the startup function. Example:

$(...)
  .each(function() { $(this).data('title', this.title) })
  .popover(options);
    
02.01.2014 / 17:03
1

You can use only CSS for building Tooltips, like this:

CSS

*{
    font-family: Arial, sans-serif;
}
div > .tooltip, li > .tooltip, a > .tooltip, span > .tooltip {
  opacity: 0;
  visibility: hidden;

  -webkit-transition: 0.3s;
  -moz-transition: all 0.3s;
}

  div:hover > .tooltip, li:hover > .tooltip, a:hover > .tooltip, span:hover > .tooltip,
  a .tooltip:hover, span .tooltip:hover, li .tooltip:hover, div .tooltip:hover {
    opacity: 1;
    visibility: visible;
    overflow: visible;
    margin-top: -40px;
    display: inline;
    margin-left: -40px;

    -webkit-transition: 0.3s;
    -moz-transition: all 0.3s;
  }

.tooltip {
  background: #3378C1;
  color: #fff;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  -o-border-radius: 5px;
  border-radius: 5px;

  padding: 10px;
  margin-left: -40px;

  position: absolute;

  font-family: Arial;
  font-size: 12px;
  text-decoration: none;
  font-style: normal; 

  z-index: 10;  
}

    .tooltip:before { /* Triangle */
      content: "";
      background: #3378C1;

      border: 0; 

      width: 10px;
      height: 10px;
      margin-left: 5px;
      margin-top: 20px;

      display: block;
      position: absolute;

      -webkit-transform: rotate(-45deg);
      -moz-transform: rotate(-45deg);
      -o-transform: rotate(-45deg);
      transform: rotate(-45deg);


      display /*\**/: none;
      *display: none !important;
      *display: none;
    }


**HTML**
   
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<br>
<br>
  <p>Este é exemplo demonstrativo de utilização de 
<a href="#"><strong>Tooltips</strong>
<span class="tooltip">
  Clique aqui e abra este link 
</span></a> 
e com isto fornecer mais uma ferramenta para seu website.</p>

Take a look at the example by running here .

    
30.01.2014 / 22:04
0

You can customize the options when you initialize the popover and return the title attribute pro original value.

$('a').popover({
  container: 'body',
  html: true,
  template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
  content: function () {
      $(this).attr('title', $(this).attr('data-original-title'));
      return $(this).text();
  },
  placement: 'auto right'
});

Example: link

    
30.01.2014 / 05:33