I have 5 questions in a form, and a few of them have a YES / NO response. I wanted to just be able to toggle the yes and no buttons once the user selected one of them. The i
You need to add a unique id or class for each button and link a click function for each button like this:
$('.btn-toggle').click(function() {
$(this).toggleClass('active');
console.log($(this));
});
$('.btn-toggle2').click(function() {
$(this).toggleClass('active');
console.log($(this));
});
$('.btn-toggle3').click(function() {
$(this).toggleClass('active');
console.log($(this));
});
$('.btn-toggle4').click(function() {
$(this).toggleClass('active');
console.log($(this));
});
Or you can group them together like this if they have a common function:
$('.btn-toggle', '.btn-toggle2', '.btn-toggle3', '.btn-toggle4') .click(function() {
$(this).toggleClass('active');
console.log($(this));
});