jQuery Snippet To Create A Responsive Show/Hide Toggle Declaratively With Data Attributes

declarativeToggle is a jQuery snippet that makes it easy to reveal sections of content in the click/tap event (think mobile navigation menus on responsive sites). Add Show/Hide functionality without writing a single line of JavaScript using data attributes.

showhide div with animation javascript, jquery show hide animation slide, javascript showhide div by class, jquery showhide list items, show hide div jquery by id

jQuery Plugin That Transforms A HTML Select Input Into A Toggleable Button

How to make use of it:

1. Load the jQuery library and jQuery signatureativeToggle plug-in into your document.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 
<script src="jquery.declarativeToggle.js"></script>

2. Create a toggle button. Use data-toggle-target to specify the target section of the content.

<span data-toggle-target="#example-1" data-toggle-text"Read less">Read more</span>

3. Insert your content into the DIV container which is the target of the toggle button.

<div id="example-1">
  ...
</div>

4. Required CSS styles to hide the content section on page load.

.toggle-btn-visible {
  position: static;
  visibility: visible;
}

.toggle-target-hidden { display: none; }

.toggle-target-expanded { display: block; }

5. You can adjust response behavior using CSS3 media queries.

@media screen and (max-width: 767px) {

.toggle-btn-visible {
  position: static;
  visibility: visible;
}

.toggle-target-hidden { display: none; }

.toggle-target-expanded { display: block; }

}

Responsive & Accessible jQuery Show/Hide Toggle Plugin, declarativeToggle Github, jquery show hidden element, onclick button show hide div using jquery, hide class in jquery


See Demo And Download

Official Website(LearnWebCode): Click Here

This superior jQuery/javascript plugin is developed by LearnWebCode. For extra Advanced Usages, please go to the official website.

Related Posts

Confetti-Falling-Animation-Effect-party

Confetti Falling Animation Effect In JavaScript | party.js

Party.js is a JavaScript library to brighten user site experience with visual effects! Celebrate success with dom confetti! The library is written in TypeScript and compiled into…

Star-Rating-JavaScript

Select Box Based Star Rating JavaScript Library | star-rating.js

star-rating.js is a small JavaScript library to create a customizable and gradually improved star rating control from a regular tick box with numeric values. The ES6 module…

Bootstrap-Show-Notification

Corner Fixed Notifications Alerts With Bootstrap | BS4 Show Notification

Bootstrap Notification is an easy-to-use jQuery plugin that uses the Bootstrap Alerts component to create static, rejectable, and stackable notification popups in the upper right corner of the…

Stackable-Multi-level-Sidebar-Menu

Create Stackable Multi-level Sidebar Menu | HC Off-canvas Nav

Multi-Level Sidebar Slide Menu – HC MobileNav is a jQuery plugin for creating multi-level, mobile-first, totally accessible, off-canvas facet navigation that helps the infinite nesting of submenu…

vue-masonry-gallery

Responsive Masonry Layout with SSR Support for Vue 3 | vue-masonry-wall

Vue masonry wall is a responsive masonry layout component for Vue 3 to deliver a Masonry-style responsive grid layout with SSR and RTL layout support. Features 📱…

bootstrap-5-bs-toaster

A Bootstrap 5 Toast Notification Framework Library | bs-toaster

bs-toaster is simple to instantiate bs-toaster and create multiple toasts effortlessly using native Bootstrap 5! Feature Facts Small and clean Modern browser support. No IE sorry 💥…