0

I have Three card with some content inside that content I set propertie display none with css and I let icon show , I want to click on that icon and the content show with JavaScript and this is my code but is not working

let show = document.querySelectorAll(".transparent");
let icon = document.querySelectorAll("card-one a");

icon.onclick = function(){
  show.style.display = "block"
                
}
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Asmae
  • 1
  • Please visit [help], take [tour] to see what and [ask]. Do some research, search for related topics on SO; if you get stuck, post a [mcve] of your attempt, noting input and expected output, preferably in a [Stacksnippet](https://blog.stackoverflow.com/2014/09/introducing-runnable-javascript-css-and-html-code-snippets/) – mplungjan Mar 12 '22 at 12:14
  • Error #1: you need the dot in the second querySelector. Error #2 you get a nodeList back, so you have to loop. Suggestion: delegate like this 1. Wrap the cards in a container. I assume each card is a div and I create a class called hide which is just display:none: `document.getElementById("cardContainer").addEventListener("click",function(e) { if (tgt.matches(".card-one")) { tgt.closest("div").querySelector(". transparent").classList.toggle("hide")} })` – mplungjan Mar 12 '22 at 12:19

0 Answers0