admin管理员组

文章数量:1391836

HTML CODE :

<select name="options" id="options" style="width: 100%;" size="12">
        <option id="optList1" value="1">
            1. ABC
        </option>
</select>

Javascript :

document.getElementById('optList1').ondblclick = function () {
            alert("asf");
        };

I am having list in of options in select , in sample there is only one item . Issue is I need to open dialog box on double click of this option... Its working fine in Chrome and Firefox , issue is mon , not working in IE....

DEMO

Any help super appreciated... Thanks in advance....!!

HTML CODE :

<select name="options" id="options" style="width: 100%;" size="12">
        <option id="optList1" value="1">
            1. ABC
        </option>
</select>

Javascript :

document.getElementById('optList1').ondblclick = function () {
            alert("asf");
        };

I am having list in of options in select , in sample there is only one item . Issue is I need to open dialog box on double click of this option... Its working fine in Chrome and Firefox , issue is mon , not working in IE....

DEMO

Any help super appreciated... Thanks in advance....!!

Share Improve this question asked Jan 25, 2013 at 12:30 Pratik BhattPratik Bhatt 9112 gold badges8 silver badges21 bronze badges 5
  • Where are you using jquery ? Or did you mean to say you wanted a jquery answer? – Ravi Y Commented Jan 25, 2013 at 12:32
  • I also tried with jQuery bt result was same it was not working... if you know that jQuery can solve this... we can use... not issue....!! – Pratik Bhatt Commented Jan 25, 2013 at 12:33
  • You can't do this in IE. select element is created by OS, not by browser. – Teemu Commented Jan 25, 2013 at 12:33
  • 1 @Teemu any link..... to support this....!! – Pratik Bhatt Commented Jan 25, 2013 at 12:34
  • @PratikBhatt I'm sorry, I can't recall the page at MSDN, and having not time to search just now... – Teemu Commented Jan 25, 2013 at 12:37
Add a ment  | 

2 Answers 2

Reset to default 3
document.getElementById('options').ondblclick = function () {
       var optio = options.options;
var id      = options[options.selectedIndex].id;
   if(id == "optList1")
   {
      alert("abc");
   }
   else 
   {
      alert("xyz")
   }
};


<select name="options" id="options" style="width: 100%;" size="12">
    <option id="optList1" value="1.1">
        2. Enter/Update W/H Data Manually
    </option>
    <option id="optList2" value="1.1">
        1. Enter/Update W/H Data Manually
    </option>

Try this code its working fine on IE

IE does not support events on <option> tag.

Also seems strange to consider a doubleclick event on <option> as this is not anything most users would be used to doing

本文标签: javascriptDouble click event not working in Internet Explorer for option listStack Overflow