jquery - Twitter Bootstrap : How to see the state of a toggle button?

标签 jquery twitter-bootstrap

如何查看切换按钮的状态?

使用复选框,我可以监听复选框的“已更改”事件,并执行 $(this).is(":checked") 来查看它的状态。

<a id="myId" class="btn" data-toggle="button"/>

但不确定如何使用切换按钮来做到这一点?

最佳答案

你可以看到按钮有哪些类..

$(this).hasClass('disabled') // for disabled states
$(this).hasClass('active') // for active states
$(this).is(':disabled') // for disabled buttons only

is(':disabled') 适用于按钮,但不适用于链接 btns

关于jquery - Twitter Bootstrap : How to see the state of a toggle button?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13323671/

相关文章:

javascript - JavaScript 中的 typeof() 函数错误

python - 使用 Bootstrap 和 Django

css - 并排 Bootstrap 表与 Angular 5 中的 *ngFor

javascript - 使用javascript将json显示为html

jquery - CodeMirror,在 keyup 上更新 iframe 脚本

html - 如何使选项卡索引适用于下拉菜单?

jquery - 顶部的 Bootstrap 多级子菜单

jquery - 如何在具有绝对位置的 Bootstrap slider 之后放置内容

javascript - 从数组中删除字符串多个键名

javascript - 单击链接以滚动到特定的 div (jquery)