📜  javascipt 切换两个按钮 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:17.695000             🧑  作者: Mango

代码示例1
function bindButtons(){
  var buttons = $('#buttons button');

  buttons.on('click', function(e){
    var $this = $(this);
    buttons.removeClass('selected').addClass('disabled');
    $this.addClass('selected').removeClass('disabled');

    switch ($this.attr('id')){
        case 'yes': 
            val = true;
            break;
        case 'no': 
            val = false;
            break;
    }
    //do something with val
  })
}