Shortcut for JQuery if/else Statement: Handling the JQuery API

// Basic: if (a) { $('div').addClass('active'); } else { $('div').removeClass('active'); } // Shortcut $('div')[a ? "addClass" : "removeClass"]('active');

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.