JSFiddle - React, Tailwind, and code Playground
by gabbymarley
JavaScript
var currentAccordion;
jQuery(document).ready(function() {
$('.accordion-header').on('click',function(event){
event.preventDefault();
var thisAccordion = $(this).attr('id'); //what was selected
if(currentAccordion == thisAccordion){ //is it already open
$(this).next('.accordion-content').toggle(); //open, close it
}else{
$('.accordion-content').hide(); //close all
$(this).next('.accordion-content').toggle(); //open new
}
currentAccordion = thisAccordion; //set new accordion
$(this).ScrollTo(); //scroll screen to top
});
$('.btn-close').on('click',function(event){
event.preventDefault();
$('.accordion-content').hide();
var thisID = $(this).parents('.accordion').find('.accordion-header').attr('id');
console.log(thisID);
$('#'+thisID).ScrollTo();
});
});
jQuery(document).ready(function() {
jQuery("[name=toggler]").click(function() {
jQuery('.toHide').hide();
var toShow = $(this).is(":checked") ? "blk-1" : "blk-2";
jQuery("#" + toShow).toggle(1);
});
$( ".touchable_swipe_mobile" ).on( "swipeleft", swipeleftHandler );
$( ".touchable_swipe_mobile" ).on( "swiperight", swiperightHandler );
// Callback function references the event target and adds the 'swipeleft' class to it
function swipeleftHandler( event ){
event.stopImmediatePropagation();
event.preventDefault();
$('#blk-1').show();
$('#blk-2').hide();
$(".toggle").removeClass("toggle_left_cls");
$(".toggle").addClass("toggle_right_cls");
var checkBoxes = $("input[name=toggler]");
checkBoxes.prop("checked", !checkBoxes.prop("checked"));
}
// Callback function references the event target and adds the 'swiperight' class to it
function swiperightHandler( event ){
event.stopImmediatePropagation();
event.preventDefault();
$('#blk-1').hide();
$('#blk-2').show();
$(".toggle").removeClass("toggle_right_cls");
$(".toggle").addClass("toggle_left_cls");
var checkBoxes = $("input[name=toggler]");
...