개발/javascript & jquery
해당 id의 tr 갯수 가져오기 그리고 if문으로 해당 객체 존재하는지 여부 체크
멋진놈
2022. 8. 30. 13:46
728x90
var rows = document.getElementById("resTb").getElementsByTagName("tr");
console.log("123214124124", rows.length); // tbody tr 개수 = 2
if(rows.length == 0){
console.log("jquery : 해당 객체 존재하지 않음");
console.log("testsdfsafa12321412412");
$("#12345").attr("value", "bad");
test.innerHTML = "<td id=\"noRes\" colspan=\"7\" value=\"noRes\">팝업창에서 항목을 선택해주세요.</td>";
} else {
console.log("jquery : 해당 객체 존재함");
$("#12345").attr("value","good");