자바스크립트 주소 이동 이벤트
본문
게시판에서 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');
    }
  });
});
                답변을 작성하시기 전에 로그인 해주세요.
            
    
