5
작은 화면에서 붕괴하는 반응 형 메뉴 표시 줄을 디자인하려하지만 typescript를 사용하고 있습니다. 내가 타이프이 코드로 변경 타이프 라이터typescript에서 클래스 이름별로 요소를 선택하는 방법은 무엇입니까?
function myFunction() {
document.getElementsByClassName("topnav")[0].classList.toggle("responsive");}
이 코드에 어떤 상응하는 단서가 있지만 결코 작동하지 않습니다
타이프 라이터 자바 스크립트의 상위 집합이기 때문에 아무것도 변경할 필요가 없습니다myFunction(): void {
(<HTMLScriptElement[]><any>document.getElementsByClassName("topnav"))[0].classList.toggle("responsive");
}
감사 @NitzanTomer – kero