简体   繁体   中英

How to make an twitter bootstrap radio button unselectable using jquery

I have an radio button group as below:

<div class="btn-group" data-toggle="buttons-radio">
    <a href="#1" class="btn btn-primary btn-andares" data-toggle="tab">1º Andar</a>             
    <a href="#2" class="btn btn-primary btn-andares active" data-toggle="tab">2º Andar</a>                  
    <a href="#3" class="btn btn-primary btn-andares" data-toggle="tab">3º Andar</a>                 
</div>

When I click in any button an current image is displayed for me. The problem is, when I click in an button which is already toggled, the current image is reloaded. How can I disable, or block the user from clicking in a button which is already selected?

I tried to use this:

$('.btn-andares').click(function(e) {
        if($(this).is(':checked')) {
            alert("already checked");
        }
    });

But it doesn't work.. what else can I do?

Return false:

$('btn-group').on('click', '.btn-andares', function(e) {
    return !$(this).hasClass('active');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM