미디어위키:Common.js: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
1번째 줄: 1번째 줄:
$(document).ready(function() {
$(document).ready(function() {
     var count = 1;  // 숫자 시작
     var count = 1;  // 숫자 시작
   
    // 목차 자체(#toc)는 제외하고, 본문 제목(h2~h6)만 선택
    $('h2, h3, h4, h5, h6').filter(function() {
        return $(this).attr('id') !== 'toc';
    }).each(function() {
        var $this = $(this);


    $('h2, h3, h4, h5, h6').each(function() {
        // 숫자 링크 생성
         var backLink = $('<a>')
         var backLink = $('<a>')
             .attr('href', '#toc')   // 목차 id
             .attr('href', '#toc')
             .text(' [' + (count++) + ']') // 숫자 표시
             .text(count + '. ')   // 숫자 + 점 + 공백
             .css({
             .css({
                 'font-size': 'small',
                 'text-decoration': 'none',
                 'margin-left': '10px',
                 'color': 'inherit',       // 부모(제목) 폰트 색깔 그대로
                 'text-decoration': 'none', // 밑줄 없애기
                 'font-size': 'inherit',   // 부모(제목) 폰트 크기 그대로
                 'color': 'gray'             // 살짝 변경
                 'margin-right': '5px'     // 숫자와 제목 간 살짝 띄우기
             });
             });


         $(this).append(backLink);
        // 숫자를 제목 맨 앞에 삽입
         $this.prepend(backLink);
 
        count++;
     });
     });
});
});

2025년 4월 26일 (토) 21:28 판