Twitter Bootstrap:如何查看切换按钮的状态? [英] Twitter Bootstrap: How to see the state of a toggle button?
本文介绍了Twitter Bootstrap:如何查看切换按钮的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何查看切换按钮的状态?
How do I see the state of a toggle button?
通过一个复选框,我可以侦听该复选框的"changed"事件,并执行一个$(this).is(":checked")
来查看其状态.
With a checkbox I can listen to "changed" event of the checkbox and do a $(this).is(":checked")
to see what state it has.
<a id="myId" class="btn" data-toggle="button"/>
但是不确定如何使用切换按钮吗?
But not sure how to do that with a toggle button?
推荐答案
您可以看到按钮具有哪些类.
you can see what classes the button has..
$(this).hasClass('disabled') // for disabled states
$(this).hasClass('active') // for active states
$(this).is(':disabled') // for disabled buttons only
is(':disabled')
适用于按钮,但不适用于btns链接
the is(':disabled')
works for buttons, but not the link btns
这篇关于Twitter Bootstrap:如何查看切换按钮的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文