Use jQuery to hide a DIV when the user clicks outside of it
Use jQuery to hide a DIV when the user clicks outside of it
Use jQuery to hide a DIV when the user clicks outside of it
Two main issues with your original code: 1- Using a wrong selector for the onchange event, replace “Other” by “#title” 2- You were checking if the value is equal to “Other” instead of the “other” you have in your HTML. Be careful, string comparison is case-sensitive! Below is a working snippet after applying these two … Read more
get the id or class of your ad with var ad = document.querySelector(“adId or adClass”) get the id or class of your button that wil go underneath your add with var button = document.querySelector(“buttonId or buttonClass”) then add a click event on the button with button.addEventListener(“click”, function(e){ ad.remove()})