Twitter Bootstrap How to see the state of a toggle button

0 votes

How do I see the state of a toggle button?

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?

May 12, 2020 in JQuery by kartik
• 37,510 points
1,432 views

1 answer to this question.

0 votes

Hii @kartik,

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

this is(':disabled') works for buttons, but not the link btns

Thank You!!

answered May 12, 2020 by Niroj
• 82,880 points

Related Questions In JQuery

0 votes
1 answer
0 votes
1 answer

How to set the 'selected option' of a select dropdown list with jquery

Using the jQuery change() method; you can ...READ MORE

answered Jun 17, 2022 in JQuery by rajatha
• 7,640 points
12,720 views
0 votes
1 answer

How to remove close button on the jQuery UI dialog?

Hii, I found this worked for me in the end ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,880 points
4,353 views
0 votes
1 answer

How to get the children of the $(this) selector?

Hello @kartik, The jQuery constructor accepts a 2nd ...READ MORE

answered Sep 10, 2020 in JQuery by Niroj
• 82,880 points
380 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,880 points

edited Jan 21, 2020 by Niroj 807 views
0 votes
1 answer

What is data binding in AngularJS?

Data binding is synchronization of data between the ...READ MORE

answered Jan 23, 2020 in Web Development by Niroj
• 82,880 points
850 views
0 votes
1 answer

How can we avoid my php form from hacking?

Hii @kartik, If you want to know php ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,880 points
2,308 views
0 votes
1 answer

How can you display the error messages?

Hey, In the HTML form, we add ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,880 points
2,967 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,880 points
2,984 views
0 votes
1 answer

How to enable Bootstrap tooltip on disabled button?

Hii @kartik, You can wrap the disabled button ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,880 points
4,683 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP