기본적으로 a태그는 클릭시 페이지가 리로드 된다.
이러한 기본행위 때문에 특정 코드가 실행이 끝나버린다.
실행 종료를 예방하기위해 쓰는 코드가
.preventDefault();
window.addEventListener("load",function(){
var section = document.querySelector("#section4");
var tbody = section.querySelector(".notice-list tbody")
tbody.onclick = function(e){
e.preventDefault(); //기본행위를 막음.
//예) a태그를 클릭시 페이지로드가 되는것 등.
var target = e.target;
if(target.nodeName != "A") return;
//document.body.classList.contains = "sel-button";
if(target.classList.contains = "sel-button"){
var tr = target.parentElement;
for(; tr.nodeName != "TR"; tr = tr.parentElement);
tr.style.background = "yellow";
}
}
});