<script>
document.getElementById("btn_hdcate")[0].click();
</script>
이렇게 화면이 켜지면 클릭 이벤트를 발생하게 스크립트를 작성하였습니다.
근데
Uncaught TypeError: Cannot read property '0' of null
이러한 에러가 나면서 실행이 되지 않아 문제입니다 ㅠㅠ
해결방법이 있을까요 ㅠ?
답변 2개 / 댓글 5개
채택된 답변
+20 포인트
마르스컴퍼니
2021-02-01 (월) 18:22:31
document.getElementById("btn_hdcate").click();
답변에 대한 댓글 4개
qoqofh
2021-02-01 (월) 18:26:10
Uncaught TypeError: Cannot read property 'click' of null 이렇게 뜨넹 ㅛㅠㅠ
마르스컴퍼니
2021-02-01 (월) 18:28:18
버튼 엘리멘트가 나온 뒤에 코드가 실행되도록 해주면 됩니다.
ex.
<button type="button" id="btn_hdcate">버튼1</butoon>
<script>
document.getElementById("btn_hdcate").click();
</script>
ex.
<button type="button" id="btn_hdcate">버튼1</butoon>
<script>
document.getElementById("btn_hdcate").click();
</script>
2021-02-01 (월) 18:29:03
Copy
window.onload = function(e){
document.getElementById("btn_hdcate").click();
}
답변에 대한 댓글 1개
답변을 작성하려면 로그인이 필요합니다.