lit / lit-element

LEGACY REPO. This repository is for maintenance of the legacy LitElement library. The LitElement base class is now part of the Lit library, which is developed in the lit monorepo.
https://lit-element.polymer-project.org
BSD 3-Clause "New" or "Revised" License
4.49k stars 319 forks source link

on click event of button want to toggle dropdown #1091

Closed anjneeksharma closed 4 years ago

anjneeksharma commented 4 years ago

If user click on button on click events its calling one function that function should toggle drop down but I am using let drop = document.querySelector(".classname"); but this statement is returning me null instead of that drop down.

is someone can help me how can i update dropdown based on it class

toggleDropdown(e) { let abc = document.querySelector(".newclass"); console.log(abc); }

sorvell commented 4 years ago

The description is a little unclear and it would be helpful to have a reproduction of the issue. However, maybe it's possible that you're trying to use document.querySelector to try to find an element that's in your element's shadowRoot? If so, you'd need to do this.shadowRoot.querySelector instead of document.querySelector.

sorvell commented 4 years ago

Closing based on previous answer. Please feel free to re-open if the problem persists.