Toggling Divs with jQuery
How do I make an toggling divs with jquery?
Found from Stack Overflow: http://stackoverflow.com/questions/17460116/expand-and-collapse-a-div-using-javascript. What is a toggling divs with jquery? How do you make a toggling divs with jquery? This script and codes were developed by Yying6 on 13 December 2022, Tuesday.
Toggling Divs with jQuery - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Toggling Divs with jQuery</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container"> <div class="header"><span>Expand</span> </div> <div class="content"> <ul> <li>This is just some random content.</li> <li>This is just some random content.</li> <li>This is just some random content.</li> <li>This is just some random content.</li> </ul> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Toggling Divs with jQuery - Script Codes CSS Codes
.container .content { display: none; padding : 5px;
}
Toggling Divs with jQuery - Script Codes JS Codes
$(".header").click(function () { $header = $(this); //getting the next element $content = $header.next(); //open up the content needed - toggle the slide- if visible, slide up, if not slidedown. $content.slideToggle(500, function () { //execute this after slideToggle is done //change text of header based on visibility of content div $header.text(function () { //change text based on condition return $content.is(":visible") ? "Collapse" : "Expand"; }); });
});
Developer | Yying6 |
Username | yying6 |
Uploaded | December 13, 2022 |
Rating | 3 |
Size | 1,967 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 |
Select Multiple Box | 2,017 Kb |
Sharp box shadow | 1,650 Kb |
Standard Thumbnail Grid | 2,108 Kb |
Framer.js basic scrolling | 1,522 Kb |
CSS3 Circle | 1,471 Kb |
Toggle Button | 1,890 Kb |
Changing Hover Color with CSS Transitions | 1,805 Kb |
Text Highlight Color | 2,201 Kb |
Select Box CSS Styling | 2,290 Kb |
Helvetilist | 2,492 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 |
Alter bg opacity on hover... | Chrisboon27 | 2,054 Kb |
FontAwesome icons with animation | Nicotinell | 2,083 Kb |
Off Canvas | Mariamarica | 1,870 Kb |
Animated SVG stroke-dasharray | Netsi1964 | 3,179 Kb |
STAR WARS LIGHTSABER | Francoiscoron | 4,420 Kb |
Transition | Shayhowe | 1,632 Kb |
Dragonball Dragon Radar | DouglasGlover | 2,157 Kb |
Cant get enough icecream in pure css3 | Melawire | 4,322 Kb |
Waveform function for a siren tone modulation | Clafou | 1,656 Kb |
Learning canvas drawing | Aurer | 2,204 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!