1
표에 표 행을 표시하거나 숨기는 필터가 거의없는 상태에서 표시 행이 없는지 확인한 다음 행이 없다는 메시지를 표에 추가합니다.어떻게 다음 줄로 이동하기 전에 자바 스크립트에서 줄을 실행하도록 할 수 있습니까?
이것은 어떻게 처리하려합니까?하지만 비참하게 실패합니다. JS가 라인을 실행하는 방식을 알고 있지 않을 수도 있습니다. 항상 비동기 일 수 있습니다.
HTML
<input ID="cbFreshFruits" Checked="true" onclick="ToggleFruits(this)" />
스크립트
문제 개발자 도구에서 확인, JS이 문을 실행
function ToggleFruits(elm) {
$target = $('#fruitTable tr[data-status="' + elm.id + '"]').filter(function() {
var crates = $("#crateTable tr .selected").parent().map(function() {
return $(this).data("crateID");
}).get();
return crates.indexOf($(this).data("crateID")) >= 0;
});
if (elm.checked) {
$target.show("down");
}
else {
$('#fruitTable tr[data-status="' + elm.id + '"]').hide("up");
}
CheckFruitExists();
}
function CheckFruitExists() {
$("#NoFilteredFruits").hide();
$("#fruitTable").show();
if ($("#fruitTable tr:visible").length < 1) {
$("#NoFilteredFruits").show();
$("#fruitTable").hide();
}
}
if ($("#fruitTable tr:visible").length < 1)
이 앞의 else {
$('#fruitTable tr[data-status="' + elm.id + '"]').hide("up");
}
의미는 실행하지만 변경되지 않았습니다. 예 : if 문을 실행하기 전에 행을 숨기지 않습니다.
다른 장소에서 CheckFruitExists
을 사용 중이므로 별도로 보관하고 싶습니다.
HTML ** END UP **이 페이지에 어떻게 렌더링됩니까? 나는 태그에 대해 들어 본 적이 없다. –
Jhecht
실행 흐름을 어떻게 확인합니까? – Vishwanath
@Vishwanath 개발자 도구를 사용하여 확인했습니다. 이미 질문 :-) – Mathematics