Remove Class On Click Outside
How do I make an remove class on click outside?
What is a remove class on click outside? How do you make a remove class on click outside? This script and codes were developed by Parth Viroja on 03 September 2022, Saturday.
Remove Class On Click Outside - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Remove Class On Click Outside</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <ul> <li class="dropdown"></li> <li class="dropdown active"></li> <li class="dropdown"></li> <li class="dropdown"></li> <li class="dropdown"></li> <li class="dropdown active"></li> <li class="dropdown active"></li> <li class="dropdown"></li> <li class="dropdown"></li> <li class="dropdown"></li> <li class="dropdown active"></li> <li class="dropdown"></li>
</ul> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Remove Class On Click Outside - Script Codes CSS Codes
body { padding:50px; display:block;
}
li { display:inline-block; height:100px; width:100px; margin:3px; -webkit-transition: all .25s ease-in-out; -moz-transition: all .25s ease-in-out; -ms-transition: all .25s ease-in-out; -o-transition: all .25s ease-in-out; transition: all .25s ease-in-out;
}
.dropdown { background:#ccc;
}
.active { background:#990000; box-shadow:0px 0px 10px rgba(0,0,0,0.4);
}
Remove Class On Click Outside - Script Codes JS Codes
// remove all .active classes when clicked anywhere
hide = true;
$('body').on("click", function () { if (hide) $('.dropdown').removeClass('active'); hide = true;
});
// add and remove .active
$('body').on('click', '.dropdown', function () { var self = $(this); if (self.hasClass('active')) { $('.dropdown').removeClass('active'); return false; } $('.dropdown').removeClass('active'); self.toggleClass('active'); hide = false;
});
Developer | Parth Viroja |
Username | parthviroja |
Uploaded | September 03, 2022 |
Rating | 3 |
Size | 1,992 Kb |
Views | 38,456 |
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 |
Responsive grid with filter, sort and layout | 2,993 Kb |
Custom checkbox and radio with menu | 2,288 Kb |
3D-box | 2,346 Kb |
Page load animation | 2,511 Kb |
Text Shapes | 1,928 Kb |
MY CV | 4,057 Kb |
Ripple Effect | 2,548 Kb |
Ubuntu Terminal | 2,603 Kb |
Jquery Tab | 2,367 Kb |
Slide up down | 1,833 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 |
The Monty Hall Problem | Melatonind | 4,360 Kb |
Knockout Lists | Marinru | 2,531 Kb |
SVG Text Masking | JMChristensen | 2,141 Kb |
Resizable SASS Icons | Marianarlt | 7,611 Kb |
Birthday Party Starter | Aussieyang | 1,629 Kb |
Sexy Social Buttons | Ipiyale | 2,226 Kb |
Pagepilling.js | Blossk | 6,554 Kb |
STAR WARS LIGHTSABER | Francoiscoron | 4,420 Kb |
Weather App | Kw7oe | 3,162 Kb |
AngularJS Datalist Directive | M-e-conroy | 2,366 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!