JS
css 선택자를 사용하는 방법
brilliant-growth
2024. 1. 2. 13:56
css 선택자를 사용하여 자바스크립트의 이벤트들을 조작하는 방법
//자바스크립트
$("[id^='MstCode']").click(function(){
var idValues = $(this).attr("id").split("_");
$("#basicTbody *").remove();
})
//HTML
th:id="'MstCode_'+${selectMstCode.CODE_NO}"
id^= 'MstCode' 의 뜻은
아이디가 MstCode로 시작하는 모든것들 이라는뜻
예를들어 MstCode_asd , MstCode_qwe , MstCode_zxc 다 선택이됨
idValues를 통하여 아이디의 값을 찾음
basicTbody 밑에 있는 모든값(*) 리무브