JSFiddle - React, Tailwind, and code Playground

by batcave

HTML

<div class="comes-with mandatory" data-am-dropdown="">1</div>
<div class="comes-with mandatory" data-am-dropdown="">2</div>
<div class="comes-with mandatory" data-am-dropdown="">3</div>
<div class="comes-with" data-am-dropdown="">4</div>

<button class="js-click-me">click me</button>

CSS

.comes-with {
	padding: 1rem;
	margin-bottom: 1rem;
	background-color: deepskyblue;
}

JavaScript

$('[data-am-dropdown]').on('click', function() {
	const dropdowns = $('[data-am-dropdown].comes-with.mandatory').get();
	var index = dropdowns.indexOf(this);
	
	dropdowns.splice(index, 1);
});