選択、ボタン、および入力要素を含む html フォームがあります。
<form action="">
<button>innocent button</button>
<select multiple name="multiple">
<option selected value="a">A</option>
<option value="b">B</option>
</select>
<input style="width:300px" type="text" value="press here enter and look at the multiple select" name="" />
</form>
そしていくつかのjquery javascript
$(document).ready(function(){
console.log('hi');
var $button = $('button');
$button.on('click',function(e){
$('select option').first().attr('selected',false);
e.preventDefault();
});
デモ: ここで試してみてください: http://jsfiddle.net/3Rjdh/
Chrome ではすべて問題ありません。ただし、Firefox の場合: 入力フィールドで ENTER を押すと、select 要素が選択されていません。
Firefox の何が問題になっていますか?