user995789
user995789

Reputation: 279

jquery select click and firefox

in firefox, when i click option, firefox regards select be clicked too. e.stoppropgation() or e.preventdefault() can not solve this problem. is it possible to stop option click event just like in chrome? Thanks for your idea.

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

Upvotes: 2

Views: 1933

Answers (3)

Rafay
Rafay

Reputation: 31033

$("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/

Upvotes: 2

Uku Loskit
Uku Loskit

Reputation: 42040

"click" is not the proper event for select elements. You should use change instead.

Upvotes: 1

Ivan
Ivan

Reputation: 15922

Don't use click event. Use change event. Firefox is doing right, you are clicking select box.

Upvotes: 1

Related Questions