Toggling Divs with jQuery

Developer
Size
1,967 Kb
Views
10,120

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 Previews

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"; }); });
});
Toggling Divs with jQuery - Script Codes
Toggling Divs with jQuery - Script Codes
Home Page Home
Developer Yying6
Username yying6
Uploaded December 13, 2022
Rating 3
Size 1,967 Kb
Views 10,120
Do you need developer help for Toggling Divs with jQuery?

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!

Yying6 (yying6) Script Codes
Create amazing art & images with AI!

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!