Entonces, creé un div en el que se puede hacer clic al poner el atributo onclick=" " de HTML, me permite mostrar mi modal personalizado, ahora en mi modal personalizado he creado otro div con onclick, ambos divs tienen la misma función como onclick ="abrir__instrumentos()".
Para entender mejor la estructura, adjunto un código:
<div class="w-full h-10 flex gap-2 relative" onclick="open__instruments()" id="creates__area"> <div class="w-full h-full shrink-0 rounded-lg text-green4 hover:text-blue-text bg-white shadow-shadow1 flex justify-center items-center gap-2 hover:bg-green2 select-none"> <span class="material-symbols-rounded">add</span> <div class="w-fit h-fit font-semibold py-2.5 ">Create</div> </div> <div class="w-[11rem] p-1 bg-white shadow-xl h-fit absolute -right-[11.7rem] rounded-lg hidden" id="instruments"> <div class="w-full h-10 text-gray-600 rounded-md left_flex pl-3 hover:bg-green2 hover:text-blue-text font-semibold cursor-pointer" onclick="open__instruments()">New Area</div> <div class="w-full h-10 text-gray-600 rounded-md left_flex pl-3 hover:bg-green2 hover:text-blue-text font-semibold cursor-pointer mt-1" onclick="open__instruments()">New Parameter</div> <div class="w-full h-10 text-gray-600 rounded-md left_flex pl-3 hover:bg-green2 hover:text-blue-text font-semibold cursor-pointer mt-1" onclick="open__instruments()">New Task</div> </div> </div>y se ve así:
cuando hago clic en eso, mostrará el modal que creé:
Ahora, cuando hago clic en Nueva área o Nuevo parámetro o Nueva tarea en mi modal, el modal no se cerrará, pero cuando hago clic en el botón +crear div/ocultará el modal.
a continuación se muestra la función javascript de onclick="open__instruments()":
const open__instruments = ()=>{ if(document.getElementById('instruments').classList.contains('hidden')){ document.getElementById('instruments').classList.remove('hidden') }else{ document.getElementById('instruments').classList.add('hidden') } }¿Cómo puedo ocultar el modal haciendo clic en un menú/botón/div en mi modal? Por cierto, también he creado una función separada para alternar el modal pero aún no funciona, además, no hay ningún error en la consola.