Javascript – Using mouseover in CSS



var a='<div id="details"  onmouseover="tip(this)">';

function tip(el)
    $(this).mouseover(function() {
    var b="<div id='test'>"+el.innerHTML+"</div>";
    $(b).css("display", "inline");

Is anything wrong with the above code? I am trying to display el.innerhtml on mouserover next to the hyperlink

Best Solution

Try to expand on what you want. Give us a list of requirements spell out exactly what you want. I expect a couple of the down votes will be rescided if you do this.

For my part, try this:

<div id="details">

<script type="text/javascript">
            var $this = $(this);
            $this.append("<div id='test'>"+$this.html()+"</div>");

To show/hide would have been simple call to .show() or .hide()

If you really wanted this code:

var a='<div id="details"  onmouseover="tip(this)">'; 

Then you would have to append to the DOM:

$(document).append('<div id="details">');

And then bind your event: