왜 두 함수가 내가 thead를 클릭했을 때의 이상한 동작을하는 이유는 tbody가 확장 된 다음 축소 된 이유입니다.jQuery 함수의 이상한 동작
두 번째 함수에서 if, else 문에 경고를 추가하는 일부 테스트를 수행 할 수 있지만 if 문에만 들어가서 slideUP 만 수행합니다.
내가 알아 차린 또 다른 사실은 tbody에 단 하나의 행만 있으면 잘 작동한다는 것입니다. 왜?
나는 또한 false를 반환하려고했지만, 아무것도, 두 번이나 다른 장소에서 호출하지 않는 함수.
이 문제를 해결할 수 있으면 감사하겠습니다.
감사합니다.
Function 1
$(function() {
$("table.section thead").click(function() {
$(this).next("table.section tbody").slideToggle("slow");
});
});
Function 2
$(function() {
$("table.section thead").click(function() {
var body = $(this).next("table.section tbody");
if (body.is(":visible"))
body.slideUp("slow");
else
body.slideDown("slow");
});
});
UPDATE 표
<table>
<thead>
<tr><td>heading></td></tr>
</thead>
<tbody>
<tr><td>content1</td></tr>
<tr><td>content2</td></tr>
</tbody>
</table>
이 두 기능이 동시에 바인딩되었거나이 두 가지 시도가 동일한 작업을 수행합니까? – Sorpigal
테이블을 보여줄 수 있습니까? – hallie
OP 중복 된 질문 http://stackoverflow.com/questions/2415999/jquery-help-converting-simple-function-please-help/2416034#2416034 –