I have created a tooltip that appends a DIV with text to the page.
I have managed to get it to appear in the position i want and follow the mouse as it moves.
I was previously doing this with inline styles and updating the top, left absolute positioning co-ordinates dynamically inline.
This seems to cause performance issues so i wrote the dynamic styling to a <style> in the <head> of the dosument which works fine in Firefox but now not in IE7 or IE6.
The jsFiddle is here;
I guess i need to remove the tag from the on mouseout as well but IE seems to render it once and then always again in the same position.
I would obviously like it to work in all browsers and not suffer any massive performance hits like it was when writing inline styles.
Not sure exactly where to start, so how about my changes? As you can see, it now works just fine in Internet Explorer. Explanations for each change:
<style>element to the head. When it reaches the limit the tooltip never moves again. I switched it back to css() for you.$('#tooltip')it’s an extra lookup. Save the result of$('#tooltip')to a variable and use the variable.I did some of the work caching
$('#tooltip'), but you should do the same for$(this). mousemove is a fairly stressful event, and can be called many times within a few ms. This causes slowdown on the rendering because it waits for the script to complete.