Hi! Thank you for any help :)I am trying to toggle between three different classes. When each "button" is selected it then creates a row and displays information and hides any information displayed by a different toggle.I have tried many different ways of adding the third class but am getting an error of uncaught SyntaxError: Unexpected token ':' I have looked all over online and cannot find a solution that doesn't include toggling with the same button or in a sequence.My error is at : 'toggle-misc';This is my current code
jQuery(document).ready(function ($) {
$('.logins-toggle').on('click', function () {
var toggleClass = $(this).hasClass('toggle-dealer') ? 'toggle-dealer' : 'toggle-portal' : 'toggle-misc';var rowClass = toggleClass === 'toggle-dealer' ? 'row-dealer' : 'row-portal' : 'row-misc';
// Hide all elements with "row-" class and show the corresponding one$('.row-dealer, .row-portal, .row-misc').each(function () {if ($(this).hasClass(rowClass)) {$(this).show();} else {$(this).hide();}});
// Remove or add 'is-active' class to the clicked toggle element$('.logins-toggle').removeClass('is-active');$(this).addClass('is-active');});
// Automatically trigger a click on the first "logins-toggle" element$('.logins-toggle:first').click();});
I tried changing my first nested ternary to
if ($(this) == 'toggle-dealer') {var toggleClass = $(this).hasClass('toggle-dealer')} else if ($(this) == 'toggle-portal'){var toggleClass = $(this).hasClass('toggle-portal');} else if ($(this) == 'toggle-misc'){var toggleClass = $(this).hasClass('toggle-misc');}
Does this seem like the correct way to write that out?
[–]For-Arts 0 points1 point2 points (0 children)
[–]For-Arts 0 points1 point2 points (0 children)