English 中文(简体)
浮标(改装)
原标题:Click (mousedown) event of a select element

我有一个空洞的选定要素,在把这一要素点点击时,我想执行一些法典,但我不想看到降幅清单。

  1. When I disabled the select element I cannot catch the mousedown event.
  2. When I enable the select element I can capture the mousedown event but the dropdown list appears.

为了争辩,我想要能够点击选定要素,Javagust,扔一个警示箱,但我想阻止下级名单显示。

感谢!

最佳回答

<onmousedown 选定要素的活动,并通过制定<条码>,取消活动。

<script type="text/javascript">
    function onSelectMouseDown() {
        event.returnValue = false;
        alert("mouse down caught and cancelled");
    }
</script>

<select id="select" onmousedown="onSelectMouseDown();"></select>
问题回答

为什么不能区分一个选择要素,将某些要素总结为同一高度和宽度的四舍五入(或其它部分)中,并用这个四分之四来进行 mo变活动?

<script>
function makeDisable(){
    var x=document.getElementById("mySelect")
    x.disabled=true
}
function makeEnable(){
    var x=document.getElementById("mySelect")
    x.disabled=false
}
function f() {
makeDisable();
alert("something");
t=setTimeout("makeEnable();",1);
}
</script>

<select id="mySelect" onMouseDown="f();">
  <option value="opt1">Option 1</option>
  <option value="opt2">Option 2</option>
</select>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签