javascript : 페이지가 로드된 후 만 반환하고 $0으로 변경하므로 HTML 테이블의
가 비어 있거나 null인지 확인해야 합니다.
$0으로 변경하므로 HTML 테이블의
표의 예
<table class="tg"> <thead> <tr> <th class="tg-0lax" id="blank-spaces"></th> <th class="titles" id="this">????</th> <th class="titles">???<br></th> <th class="titles">???</th> <th class="titles">???</th> </tr> </thead> <tbody> <tr> <td></td> <td>not empty do nothing</td> <td></td> </tr> </tbody> <table>
이제 이것이 실제로 작성되는 방식으로 데이터는 API에서 각 td로 푸시되며, API가 다운되는 경우가 있습니다. jquery를 사용하여 td에 표시되는 것이 있는지 확인하고 싶습니다. td에 오류 메시지가 있는 문자열이 있기를 원합니다. 이것은 현재 시도 중인 jquery입니다.
var empty= $("td").trim().filter(function () { return this.value.trim()=== null })
empty.addClass("errorDefault");
if ($("td").hasClass("errorDefault")) {
this.val("$0");
this.text("$0");
this.html("There was an error getting data
");
}
TD에는 일반적으로 값 속성이 없습니다. 대신 innerHTML 또는 textContent 사용
ControlAltDel2022-02-14 17:53:10
$("td").each(...)와 같은 모든 셀을 반복해야 합니다(또한 관련 없는 태그로 질문에 태그를 지정하지 마십시오).
Chris G2022-02-14 17:49:17