Is it posible to make an input checkbox a Bootstrap glyphicon?

后端 未结 3 1044
一整个雨季
一整个雨季 2020-12-18 16:11

Is it posible to make an input checkbox a Bootstrap glyphicon?

I want to make up the default checkboxes with a nice Bootstrap glyphicon. For example: glyphicon

3条回答
  •  天命终不由人
    2020-12-18 16:35

    If you're able to modify your markup a bit, this should do:

    
    
    $('.glyphy').click(function (e) {
        if ($(e.target).is('input')) { // prevent double-event due to bubbling
            $(this).find('.glyphicon').toggleClass('glyphicon-check glyphicon-unchecked');
        }
    });
    

    Demo

提交回复
热议问题