2

ブートストラップを使用してウェブサイトを構築し、ラジオボタンの上にオーバーレイされたボタングループを使用して、どのラジオボタンがチェックされているかに基づいて特定のコンテンツをロードしています。ラジオ ボタンの値属性をチェックして、ロードするコンテンツを決定します (jQuery を使用)。これが同じ JSFiddle です。

http://jsfiddle.net/F2Kr3/1/

これを Chrome で実行すると、アラート プロンプトにラジオ ボタンの値が表示されます。

これを Firefox で実行すると、アラート プロンプトに「未定義」と表示されます。

何らかの理由で、FF がこのように動作している理由、または私が何か間違ったことをした理由。

前もって感謝します!

4

1 に答える 1

3

The reason why this works for Chrome is that it triggers the click event down to the input:radio level, while Firefox doesn't have this kind of behavior.

As far as I know, Bootstrap doesn't handle this functionality between buttons and nested input radio buttons. So you'll have to set the checked attribute of the input:radio buttons on click of a Bootstrap styled button.

$('div.btn-group .btn').click(function(){
  $(this).find('input:radio').attr('checked', true);
  alert($('input[name=radio-btn-ctrl]:checked').val());
});

http://jsfiddle.net/3prAu/1/

于 2012-10-04T02:23:47.653 に答える