Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery reproducing onmouseenter logic inline at element level
    primarykey
    data
    text
    <p>I have a very large HTML page whereby an enterprise user is displaying thousands of database records as part of a batch-update/validation process.</p> <p>Within the page I need to add tooltips to many of the elements. Previously we have used the trusty approach of doing this in the <code>&lt;head&gt;</code>:</p> <pre><code>$("elementID").mouseenter(function(){ // tool tip logic // goes here }); </code></pre> <p>The problem is that this is adding tens of thousands of lines of JavaScript and causing massive performance problems. So, I am researching the differences of applying this at element level instead. So rather than having the above code for each element that requires a tooltip, I am declaring a single script block like this:</p> <pre><code>function ShowTooltip(ctrl, tooltip) { var o = $(ctrl).offset(); var y = o.top; var x = o.left; $("#ttfloat").css({ top: o.top, left: o.left }); $("#ttfloat").html(tooltip); $("#ttfloat").show(); } function HideToolTip() { $("#ttfloat").hide(); } </code></pre> <p>And then firing this using the following approach for each respective element:</p> <pre><code>&lt;div id="ttfloat"&gt;&amp;nbsp;&lt;/div&gt; &lt;p&gt;Tool tip &lt;span id="lbl1" runat="server" onmouseover="ShowTooltip(this, 'Tip Text');" onmouseout="HideToolTip();"&gt;appears here&lt;/span&gt;&lt;/p&gt; </code></pre> <p>The problem is that when hovering over the <code>&lt;span&gt;</code> elements, there is a flicker of the tooltip element as the browser fires <code>onmouseover</code> repeatedly. I read on other SO solutions that JQuery mouseenter is the way to go to solve this, but can only find examples that wire up the events in the head. Can it be done in-line in the element, or is there a better way altogether? The solution must work with older browsers and be standards compliant.</p> <p>See <a href="http://jsfiddle.net/szCU2/1/" rel="nofollow">JSFiddle</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload