L'attribut de titre de création apparaît instantanément sur le vol stationnaire

Existe-t-il une possibilité de créer un attribut de titre d'une balise d'ancrage instantanément sur le passage de la souris pas seulement après quelques secondes. Toute solution dans JavaScript / jQuery et CSS est bonne.

La gestion de l'attribut title dépend du navigateur et aucune API n'a été définie pour le contrôler, encore moins spécifiée dans les spécifications. Cela inclut le délai, la durée de l'affichage, la police utilisée, la taille de la police, etc.

Il existe d'autres techniques qui peuvent être utilisées à la place de l'attribut du title . Certains d'entre eux ont été mentionnés dans d'autres réponses. Notez que les «astuces informatiques CSS» simples peuvent être implémentées dans un CSS pur, de manière simple et flexible. Lors de l'utilisation de ces techniques, les données à afficher ne sont généralement pas dans un attribut de title , car la gestion est dépendante du navigateur, de sorte qu'il y aurait un risque d'avoir votre affichage d'outil spécial et la mise en œuvre d'un navigateur. Bien qu'il soit possible d'éviter ce dernier, lorsque le script est activé, il est plus simple d'utiliser un attribut qui n'a aucun effet par défaut sur quoi que ce soit, tel que data-title=... ou data-tooltip=...

Une approche:

 // textFrom : String, the attribute from which the text // should come, // delta : String or Number, the distance from the cursor at // which the tooltip should appear function instantTooltips(textFrom, delta) { // if delta exists, and can be parsed to a number, we use it, // otherwise we use the default of 5: delta = parseFloat(delta) ? parseFloat(delta) : 5; // function to handle repositioning of the created tooltip: function reposition(e) { // get the tooltip element: var tooltip = this.nextSibling; // setting the position according to the position of the // pointer: tooltip.style.top = (e.pageY + delta) + 'px'; tooltip.style.left = (e.pageX + delta) + 'px'; } // get all elements that have an attribute from which we // want to get the tooltip text from: var toTitle = document.querySelectorAll('[' + textFrom + ']'), //create a span element: span = document.createElement('span'), // find if we should use textContent or innerText (IE): textProp = 'textContent' in document ? 'textContent' : 'innerText', // caching variables for use in the upcoming forEach: parent, spanClone; // adding a class-name (for CSS styling): span.classList.add('createdTooltip'); // iterating over each of the elements with a title attribute: [].forEach.call(toTitle, function(elem) { // reference to the element's parentNode: parent = elem.parentNode; // cloning the span, to avoid creating multiple elements: spanClone = span.cloneNode(); // setting the text of the cloned span to the text // of the attribute from which the text should be taken: spanClone[textProp] = elem.getAttribute(textFrom); // inserting the created/cloned span into the // document, after the element: parent.insertBefore(spanClone, elem.nextSibling); // binding the reposition function to the mousemove // event: elem.addEventListener('mousemove', reposition); // we're setting textFrom attribute to an empty string // so that the CSS will still apply, but which // shouldl still not be shown by the browser: elem.setAttribute(textFrom, ''); }); } // calling the function: instantTooltips('title', 15); 
 [title] { display: block; margin: 0 0 1em 0; } /* hiding, and styling, the elements we'll be creating */ [title] + span.createdTooltip { display: none; border: 2px solid #f90; background-color: rgba(255, 255, 255, 0.8); padding: 0.2em 0.5em; border-radius: 0.75em; } /* showing the created elements on hovering the element we want to show tooltips for */ [title]:hover + span.createdTooltip { display: block; position: absolute; } 
 <span title="This is the span's title">A span element</span> <img src="http://placekitten.com/g/250/250" title="A kitten." /> <input title="This is an input element's title." value="This input has a title" /> 

Vous ne pouvez pas le faire avec des info-bulles par défaut, mais vous pouvez utiliser les plugins jQuery pour info-bulle ou bootstrap. Et la meilleure façon de créer cela est de créer une info-bulle personnalisée.

http://tech.pro/tutorial/930/jquery-custom-tooltips

Voici quelques références que vous pouvez utiliser

Simpletip: http://craigsworks.com/projects/simpletip/

Bootstrap: http://getbootstrap.com/javascript/#tooltips

Bootstraps ToolTip plugin fait un très bon travail de ceci et est beaucoup plus réactif / plus rapide.

Il suffit que les fichiers Bootstrap par défaut soient exécutés.

Le CSS peut être modifié en fonction de vos besoins.

Vous trouverez plus d'informations et d'exemples ici:

http://getbootstrap.com/javascript/#tooltips

Vous pouvez cacher le tite sur mouseover et ajouter une portée. Puis retirez la portée et rétablissez le titre sur mouseout

 $('a').hover(function(e){ title = $(this).attr('title'); $(this).append('<span>Im Super Fast!!!</span>') $(this).removeAttr('title'); }, function(e){ $('span', this).remove(); $(this).attr('title',title); }); 

Vérifiez l'exemple – http://jsfiddle.net/1z3catx3/1/

Note: vous auriez bien sûr besoin de style de la span