最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Bootstrap button groups + Radio Buttons, checked value is not working in Firefox using jQuery - Stack Overflow

programmeradmin0浏览0评论

I'm building a website using bootstrap and using button groups overlaid on top of radio buttons to load certain content based on which radio button is checked . I check value attribute in radio buttons to decide which content to load (using jQuery). Here is JSFiddle for the same.

/

If you run this in Chrome then you get radio button values in alert prompts.

If you run this in Firefox then you get "undefined" in alert prompts.

Any reason, why FF is behaving this way or I have done something wrong.

Thanks in advance!

I'm building a website using bootstrap and using button groups overlaid on top of radio buttons to load certain content based on which radio button is checked . I check value attribute in radio buttons to decide which content to load (using jQuery). Here is JSFiddle for the same.

http://jsfiddle/F2Kr3/1/

If you run this in Chrome then you get radio button values in alert prompts.

If you run this in Firefox then you get "undefined" in alert prompts.

Any reason, why FF is behaving this way or I have done something wrong.

Thanks in advance!

Share Improve this question asked Oct 4, 2012 at 1:20 WizWiz 3071 gold badge6 silver badges15 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 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/3prAu/1/

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论