2011-10-29 60 views
2

在Firefox中,当我点击选项,Firefox的问候选择也被点击。 e.stoppropgation()或e.preventdefault()不能解决此问题。是否有可能停止选项点击事件就像在铬?谢谢你的想法。jQuery选择点击和火狐

<select> 
<option>test</option> 
</select> 
<p>adfadf</p> 
$(document).ready(function(){ 
$("select").click(function(){$("p").toggle();}) 
$("select option").click(function(){alert('it is weired');}) 
}) 

回答

2
$("select").click(function(){ 
     console.log('select'); 
     $("p").toggle(); 
}); 

$("select option").click(function(e){ 
    e.stopPropagation(); 
    console.log('it is not weired'); 
}); 

http://jsfiddle.net/GzNuf/

+0

是的,谢谢。我拼错停止传播。非常非常愚蠢。 – user995789

1

请勿使用点击事件。使用更改事件。 Firefox正在做对,你正在点击选择框。

1

“点击”不是select元素的适当事件。您应该使用change