2

So I have been in the process of migrating my current project from Bootstrap 2.3 to Bootstrap 3 which has had some major structural changes particularly to due with radio buttons. Currently I have

HTML:

<div class="btn-group" data-toggle="buttons">                            
  <label class="btn btn-primary">
    <input id="emViewMacsButton" name="options" type="radio">MAC
  </label>
  <label class="btn btn-primary">
    <input id="emViewTagsButton" name="options" type="radio">Tags
  </label>
  <label class="btn btn-primary">
    <input id="emViewSettingsButton" name="options" type="radio">Settings
  </label>
</div>

Script Code:

$('#emViewMacsButton').on('click',emViewMacs());
$('#emViewTagsButton').on('click',emViewTags());                      
$('#emViewSettingsButton').on('click',emViewSettings());

My problem lies in that I have setup my program that each of the different radio buttons must access a different function to display table data. The .on('click') function returns nothing. I've also tried $('input[name=options]') but the active attribute isn't set for any of the radio buttons on the returned piece of HTML . What would be the correct structure for this ?

4

1 回答 1

1

http://jsbin.com/uwezip/1/edit

将函数 ( myFunction()) 传递给另一个函数回调时,只需删除()

$(function(){ // DOM is now ready to be manipulated

    $('#emViewMacsButton').on('change',emViewMacs);
    $('#emViewTagsButton').on('change',emViewTags);                      
    $('#emViewSettingsButton').on('change',emViewSettings);

});
于 2013-08-06T21:30:44.913 回答