Greg Greg - 1 year ago 92
jQuery Question

Boostrap 3 active state button. How get total active button?

At page I have many button active state of type. I bind to the event click and check how many button have active status. But when I click at first button I get zero.

$(".btn-quote").on("click", function (e) {
var totalActiveQuote= $("").length;

if (totalActiveQuote > 0) {
} else {

What I should do to fix this?

Answer Source

This is because the active class is toggled after your onClick event fires. You could fix it by toggling it on your own.

  $(".btn-quote").on("mouseup", function (e) {
    var totalActiveQiote = $(".btn-quote.myActive").length;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download