편집 요약 없음 |
편집 요약 없음 |
||
| 1번째 줄: | 1번째 줄: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// 기존의 .custom-toggle 클릭 이벤트 핸들러 | // 기존의 .custom-toggle 클릭 이벤트 핸들러 | ||
| 53번째 줄: | 47번째 줄: | ||
$this.text('접기'); | $this.text('접기'); | ||
} | } | ||
}); | |||
// <nolinkstyle> 태그를 .nolinkstyle 클래스로 변환 | // <nolinkstyle> 태그를 .nolinkstyle 클래스로 변환 | ||
$('nolinkstyle').each(function() { | $('nolinkstyle').each(function() { | ||
| 58번째 줄: | 54번째 줄: | ||
var content = $this.html(); | var content = $this.html(); | ||
$this.replaceWith('<span class="nolinkstyle">' + content + '</span>'); | $this.replaceWith('<span class="nolinkstyle">' + content + '</span>'); | ||
}); | }); | ||
}); | }); | ||
2024년 9월 27일 (금) 09:35 판
$(document).ready(function() {
// 기존의 .custom-toggle 클릭 이벤트 핸들러
$('.custom-toggle').click(function() {
$(this).next('.custom-content').slideToggle();
});
// 새로 추가할 .toggle-collapse 클릭 이벤트 핸들러
$('.toggle-collapse').click(function() {
var $this = $(this);
var rowsToToggle = parseInt($this.data('rows')) || 1;
var isCollapsed = $this.data('collapsed') === true;
var $row = $this.closest('tr');
// 지정된 행 수만큼 다음 행을 숨기거나 표시
for (var i = 0; i < rowsToToggle; i++) {
$row = $row.next();
if ($row.length) { // 다음 행이 존재하는지 확인
if (isCollapsed) {
$row.show();
} else {
$row.hide();
}
}
}
// 상태 토글
$this.data('collapsed', !isCollapsed);
$this.text($this.data('collapsed') ? '펼치기' : '접기');
});
// 페이지 로드 시 기본 상태 설정
$('.toggle-collapse').each(function() {
var $this = $(this);
var rowsToToggle = parseInt($this.data('rows')) || 1;
var isCollapsed = $this.data('collapsed') === true;
if (isCollapsed) {
var $row = $this.closest('tr');
for (var i = 0; i < rowsToToggle; i++) {
$row = $row.next();
if ($row.length) { // 다음 행이 존재하는지 확인
$row.hide();
}
}
$this.text('펼치기');
} else {
$this.text('접기');
}
});
// <nolinkstyle> 태그를 .nolinkstyle 클래스로 변환
$('nolinkstyle').each(function() {
var $this = $(this);
var content = $this.html();
$this.replaceWith('<span class="nolinkstyle">' + content + '</span>');
});
});