srcElement的tagname和parent的tagName一起判断,或者在select外面放一个span/div,在那里捕获onmouseout

解决方案 »

  1.   

    <select onmouseout="alert(this.tagName);">
    <option onmouseout="event.stopPropagation();">1</option>
    <option>2</option>
    <option>3</option>
    </select>
      

  2.   

    to woyingjie(沃英杰) :这样每个option必须要设置,很麻烦,更麻烦的是在firefox里面,multiple select 列表框
    不管options的数量,都会自动显示垂直滚动条,而这个滚动条上是没有办法加上这个事件的。
      

  3.   

    还没试过, 不过一提到firefox就烦, 不知哪个做它出来干嘛的, 做出来又不做好点, 害得我们程序员半死
      

  4.   

    我并不认为这个firefox的事件模型不好,只是与ie不同。试想你想要精确控制select本身,就可能需要这么多事件。
      

  5.   

    把event作为参数传就可以了
    function event_test(e)
    {
        var ee = window.event || e;//这个ee就是event了
        if (ee.srcElement)
        {
            //ie 的event元素
        }
        else if (ee.target)
        {
            /firefox的event元素
        }
    }
    <select onmouseout="alert(this.tagName);">
    <option onmouseout="event_test(event);">1</option>
    <option>2</option>
    <option>3</option>
    </select>