I have one link which opens a div and it works fine, but I cannot make it to move to location of mouse click. Code is as follows:
Link:
<a href="#" onclick="show_popup('my_popup')" id="napFilt">Filter</a>
Function:
function show_popup(id) {
if (document.getElementById){
obj = document.getElementById(id);
if (obj.style.display == "none") {
obj.style.display = "";
}
}
}
Using JS, how can I make the displayed div move to the position of the mouse click?
Make sure the div you are “spawning” is in the body tag. It sould have “position: absolute;” as css property.
Then you do this: http://jsfiddle.net/GSxNx/5/
I leave this pretty uncommented here since i commented source code there. 😉
Only one thing: This is NOT! crossbrowser tested. It works though pretty well in FF 16.0 😉