select标签选择相同项后不触发onchange解决办法

 在鼠标按下是修改当前选择项

 

<select onmousedown="this.sindex = this.selectedIndex; this.selectedIndex = -1;" onblur="if(this.sindex) this.selectedIndex = this.sindex;" onchange="alert('ok'); this.sindex = undefined;">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4" selected="selected">4</option>
    <option value="5">5</option>
</select>

 

 后来发现这个小办法在火狐下不好使.    如果展开select下拉列表后不选择项,点其他地方,只是把列表框缩进去,焦点依然在,需要再次点击才会失去焦点触发函数.

不知道还有没有其他的简单可行的好办法. 

qdsang

posted @ 2011-06-30 19:10  qdsang  阅读(1737)  评论(0编辑  收藏  举报