Create a JavaScript function with some name, and then call it on the onmousedown event, passing the event and this object, which you can use inside the function.
HTML
<select onmousedown="onMouseDown(event, this)">...</select>
Js
function onMouseDown(e, obj){ e = e || window.event; //window.event for IE alert("Keycode of key pressed: " + (e.keyCode || e.which)); alert("Offset-X = " + obj.offsetLeft); alert("Offset-Y = " + obj.offsetTop); }
If you plan on using jQuery, you can use this script
$('select').mousedown(function(e){ alert("Keycode of key pressed: " + e.which);
Update:
If you want to embed a script, try this.
<select onmousedown="function(e, obj){ e = e || window.event;alert('Keycode of key pressed: ' + (e.keyCode || e.which));alert('Offset-X = ' + obj.offsetLeft);alert('Offset-Y = ' + obj.offsetTop);}(event, this);">...</select>
source share