자바스크립트 주소 이동 이벤트

자바스크립트 주소 이동 이벤트

QA

자바스크립트 주소 이동 이벤트

답변 1

본문

게시판에서 tr 태그를 클릭하면, 제목의 주소로 이동하게 자바스크립트를 작성했습니다.

화면 너비가 767px 이하일 때만 작동하게 하려면 어떻게 하나요?

 


const boardTableRow = document.querySelectorAll('.tbl_head01 tr');
 
boardTableRow.forEach(function(tr) {
  tr.addEventListener('click', function(e) {
    window.location.href = this.querySelector('.bo_tit_link').getAttribute('href');
  });
});

이 질문에 댓글 쓰기 :

답변 1


const boardTableRow = document.querySelectorAll('.tbl_head01 tr');
 
boardTableRow.forEach(function(tr) {
  tr.addEventListener('click', function(e) {
    if ($(window).width() <= 767) {
      window.location.href = this.querySelector('.bo_tit_link').getAttribute('href');
    }
  });
});
답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 0
© SIRSOFT
현재 페이지 제일 처음으로