Vanila JS Accordion
How do I make an vanila js accordion?
What is a vanila js accordion? How do you make a vanila js accordion? This script and codes were developed by Umar Hamza on 27 December 2022, Tuesday.
Vanila JS Accordion - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Vanila JS Accordion</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <html>
<head> <meta charset=utf-8> <title>jQuery Events 201</title> <link rel="stylesheet" href="style.css"> <style type="text/css"> #animatedElem { position: absolute; width: 20px; height: 20px; background: transparent; } </style>
</head>
<body>
<dl> <dt>What are your hours?</dt> <dd>We are open 24/7.</dd> <dt>What are your hours?</dt> <dd>We are open 24/7.</dd> <dt>What are your hours?</dt> <dd>We are open 24/7.</dd> <dt>What are your hours?</dt> <dd>We are open 24/7.</dd> <dt>What are your hours?</dt> <dd>We are open 24/7.</dd>
</dl>
<div id="animatedElem"><div>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> -->
<script>
// $('dd').filter(':nth-child(n+4)').addClass('hide'); // $('dl').on('mouseenter', 'dt', function() { // $(this) // .next() // .slideDown(200) // .siblings('dd') // .slideUp(200); // });
</script>
</body>
</html> <script src="js/index.js"></script>
</body>
</html>
Vanila JS Accordion - Script Codes CSS Codes
body { width: 500px; margin: auto; text-align: center;
}
dl {
}
dd { margin: 0; padding: 1em 0;
}
dt { cursor: pointer; font-weight: bold; font-size : 1.5em; line-height: 2em; background: #e3e3e3; border-bottom: 1px solid #c5c5c5; border-top: 1px solid white;
}
dt:first-child { border-top: none; }
dt:nth-last-child(2) { border-bottom: none; }
.hide { display: none;}
Vanila JS Accordion - Script Codes JS Codes
(function() {
var details = document.querySelectorAll('dd'), list = document.querySelector('dl');
for (var i = 1; i < details.length; i++) { details[i].className = 'hide';
};
list.addEventListener('click', function(e){ if (e.target.tagName === 'DT') { for (var f = 0; f < details.length; f++) { details[f].setAttribute('class', 'hide'); }; e.target.nextElementSibling.removeAttribute('class', 'hide') //console.dir(e.target) };
}, true);
//Animate the box height and then hide
setTimeout(function() {console.log('yay')}, 3000)
var elem = document.getElementById("animatedElem"), left = 0, timer;
// Move the element 10px on the right every 16ms
timer = setInterval(function() { elem.style.left = ( left += 10 ) + "px"; // clear the timer at 400px to stop the animation if ( left == 400 ) { clearInterval( timer ); }
}, 16);
})(); // iffy
Developer | Umar Hamza |
Username | umarhamza |
Uploaded | December 27, 2022 |
Rating | 3 |
Size | 2,524 Kb |
Views | 10,120 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
React Playground | 3,472 Kb |
Image Hover | 2,029 Kb |
DBrand Inspired Header | 30,441 Kb |
Directory | 22,312 Kb |
Form | 3,223 Kb |
Image Hover 2 | 1,958 Kb |
JS Prototypes | 2,093 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Velocity.js custom stagger | Tommiehansen | 4,805 Kb |
Parallax.js | Zmeeey5 | 2,330 Kb |
Nested flexbox layout for library catalog | Boycetrus | 3,271 Kb |
A Pen by utcwebdev | Utcwebdev | 2,856 Kb |
Border-radius animation | Yukulele | 2,480 Kb |
3D-box | Parthviroja | 2,346 Kb |
Chuck Norris Background | Manz | 1,967 Kb |
Feedback Page | TessDiNapoli | 2,836 Kb |
A Pen by Alexandru Pora | Axpro | 1,615 Kb |
Magnus 3 | ARocketfish | 7,944 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!