var actionList = document.getElementById("actionList");
actionList.onmouseover = function () { selectElementMouseover(actionList); }
actionList.onmouseleave = function () { selectElementMouseleave(actionList); }
function selectElementMouseover(element) {
fireEvent(element, "mousedown");
fireEvent(element, "mouseup");
}
function selectElementMouseleave(element) {
fireEvent(element, "mousedown");
}
// To fire any event from JavaScript.
function fireEvent(node, eventName) {
var doc;
if (node.ownerDocument) {
doc = node.ownerDocument;
} else if (node.nodeType == 9) {
doc = node;
} else {
throw new Error("Invalid node passed to fireEvent: " + node.id);
}
if (node.dispatchEvent) {
var eventClass = "";
// Different events have different event classes.
switch (eventName) {
case "click": // 'click' works correctly in Safari. For other we should use 'mousedown' or 'mouseup'.
case "mousedown":
case "mouseup":
eventClass = "MouseEvents";
break;
case "focus":
case "change":
case "blur":
case "select":
eventClass = "HTMLEvents";
break;
default:
throw "fireEvent: Couldn't find an event class for event '" + eventName + "'.";
break;
}
var event = doc.createEvent(eventClass);
var bubbles = eventName == "change" ? false : true;
event.initEvent(eventName, bubbles, true); // All events created as bubbling and cancelable.
event.synthetic = true;
node.dispatchEvent(event, true);
} else if (node.fireEvent) {
var event = doc.createEventObject();
event.synthetic = true;
node.fireEvent("on" + eventName, event);
}
};
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.