본문 바로가기
조회 수 64 추천 수 0 댓글 8
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
Extra Form

대략 어떤걸 숨겨야 할지는 알겠는데 문제는 공지 접기 버튼을 누르면 공지 펼치기로 바뀌는 부분과 새로고침을 해도 공지 접기나 펼치기 상태가 게시판 한정으로 반영이 되어야함. 이걸 보르겠음.

Who's 뉴리대장

profile

아이마스 좋아하는 코더.

목록
  • profile
    작성자 뉴리대장Best 2022.07.13 15:40

    감사합니다. 제이쿼리 없는 바닐라 js네요. 해당 코드 참조해서 구현해 보도록 하겠습니다.

  • ?
    갓수가되고싶따Best 2022.07.13 15:24
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8"/>
    <title>제목</title>
    </head>
    </body>
    <style>
    #toc-content {
    display: none;
    }
    #toc-toggle {
    cursor: pointer;
    color: #2962ff;
    }
    #toc-toggle:hover {
    text-decoration: underline;
    }
    </style>

    목차 [<span id="toc-toggle" onclick="openCloseToc()">보이기</span>]
    <ol id="toc-content">
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
    </ol>

    <script>
    var view_key=localStorage.getItem('view_key');
    console.log(view_key);
    if(view_key=="true"){
    document.getElementById('toc-content').style.display = 'none';
    document.getElementById('toc-toggle').textContent = '보이기';
    }else if(view_key=="false"){
    document.getElementById('toc-content').style.display = 'block';
    document.getElementById('toc-toggle').textContent = '숨기기';
    }
    function openCloseToc() {
    if(document.getElementById('toc-content').style.display === 'block') {
    document.getElementById('toc-content').style.display = 'none';
    document.getElementById('toc-toggle').textContent = '보이기';
    localStorage.setItem('view_key',true);
    } else {
    document.getElementById('toc-content').style.display = 'block';
    document.getElementById('toc-toggle').textContent = '숨기기';
    localStorage.setItem('view_key',false);
    }
    }
    </script>
    </body>
    </html>

    일단 만들어봣는데 위 소스 그대로 html 파일로 만들어서 테스트 해보시면 될듯
    생각하시는게 다를거 같아서 틀릴수도있을거같은데 개인적으로는 공부가 되서 잘 써먹을듯요
  • ?
    갓수가되고싶따 2022.07.13 14:50

    https://joshua-dev-story.blogspot.com/2020/09/javascript-collapse.html

    이 블로그 참고해보시는건 어떨지?

    고정은 css style 쪽에서 고정시키거나 따로 값을 가지고 있게해서 적용해야할거같은데 그건 좀더 찾아봐야할듯요

  • ?
    갓수가되고싶따 2022.07.13 15:10
    css 고정은 localstorage 라는게 잇어서 찾아보고있는데 얼추 정리되면 예시코드 한번 드릴수있을듯요
  • profile
    작성자 뉴리대장 2022.07.13 15:14
    일단 공지글 자체는 tr.notice만 날리면 됨. 그 날리는 버튼을 어떻게 만드는지가 문제임.
  • ?
    갓수가되고싶따 2022.07.13 15:24
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8"/>
    <title>제목</title>
    </head>
    </body>
    <style>
    #toc-content {
    display: none;
    }
    #toc-toggle {
    cursor: pointer;
    color: #2962ff;
    }
    #toc-toggle:hover {
    text-decoration: underline;
    }
    </style>

    목차 [<span id="toc-toggle" onclick="openCloseToc()">보이기</span>]
    <ol id="toc-content">
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
    </ol>

    <script>
    var view_key=localStorage.getItem('view_key');
    console.log(view_key);
    if(view_key=="true"){
    document.getElementById('toc-content').style.display = 'none';
    document.getElementById('toc-toggle').textContent = '보이기';
    }else if(view_key=="false"){
    document.getElementById('toc-content').style.display = 'block';
    document.getElementById('toc-toggle').textContent = '숨기기';
    }
    function openCloseToc() {
    if(document.getElementById('toc-content').style.display === 'block') {
    document.getElementById('toc-content').style.display = 'none';
    document.getElementById('toc-toggle').textContent = '보이기';
    localStorage.setItem('view_key',true);
    } else {
    document.getElementById('toc-content').style.display = 'block';
    document.getElementById('toc-toggle').textContent = '숨기기';
    localStorage.setItem('view_key',false);
    }
    }
    </script>
    </body>
    </html>

    일단 만들어봣는데 위 소스 그대로 html 파일로 만들어서 테스트 해보시면 될듯
    생각하시는게 다를거 같아서 틀릴수도있을거같은데 개인적으로는 공부가 되서 잘 써먹을듯요
  • ?
    갓수가되고싶따 2022.07.13 15:29
    html 코드 이대로 올려도 괜찮은지는 모르겟는데 문제가 된다면 얘기해주시면 바로 삭제하겟습니다~
  • profile
    작성자 뉴리대장 2022.07.13 15:40

    감사합니다. 제이쿼리 없는 바닐라 js네요. 해당 코드 참조해서 구현해 보도록 하겠습니다.

  • ?
    갓수가되고싶따 2022.07.13 15:42
    화이팅입니다 ^^
  • profile
    일립시S 2022.07.13 18:21

    이거 내가 파일 목록 접기 스크립트 만들어놓은 거 쿠키랑 섞어 쓰면 될 텐데


유머/자유 게시판

유머를 포함하여 국내 정치 이외의 이야기를 자유롭게 할 수 있는 게시판 입니다

  1. No Image notice

    우리 사이트는 스퀘어발 난민을 환영합니다

    Date2023.12.18 By뉴리대장 Views830 Votes5
    read more
  2. No Image notice

    사이트 이용 규칙(2024.02.23. 수정) (17)

    Date2022.06.29 By뉴리대장 Views3335 Votes33
    read more
  3. No Image notice

    수위가 있는 게시물에 대해 (3)

    Date2022.07.04 Category공지 By뉴리대장 Views1512 Votes12
    read more
  4. No Image notice

    유머/자유 게시판 이용 안내 및 규칙 (7)

    Date2022.06.29 Category공지 By뉴리대장 Views1803 Votes19
    read more
  5. 버튜버)SSRB만들기

    Date2022.06.29 Category잡담 By시시로보탄 Views72 Votes0
    Read More
  6. No Image

    철의 장막이 생겼다!!

    Date2022.06.29 Category잡담 By방사능녹조라떼 Views43 Votes0
    Read More
  7. 이제 유게이가 아니라 뉴게이인가? (12)

    Date2022.06.29 Category잡담 By똑똑한얼굴 Views68 Votes0
    Read More
  8. 빨리 베스트 생겼으면 좋겠다 (2)

    Date2022.06.29 Category잡담 By하야미카나데 Views67 Votes0
    Read More
  9. No Image

    여기도 일단 첫글

    Date2022.06.29 Category잡담 By떠달리네요 Views26 Votes0
    Read More
  10. 가입함 (1)

    Date2022.06.29 Category잡담 ByATLAS-GUNDAM Views50 Votes0
    Read More
  11. No Image

    대피소 괜찮은데? (1)

    Date2022.06.29 Category잡담 By블레이즈 Views51 Votes1
    Read More
  12. No Image

    어찌됐든 그 구멍가게는 좀 망해야함 (1)

    Date2022.06.29 Category잡담 By콘페코 Views38 Votes1
    Read More
  13. 글쓰는 거 좋아는 하는데

    Date2022.06.29 Category잡담 By푸라운 Views58 Votes0
    Read More
  14. No Image

    썸네일보이게 유툽링크거는거 어케함?

    Date2022.06.29 Category잡담 By홀로하코오시 Views55 Votes0
    Read More
  15. 간단한 글/댓글 이미지 크기 조정 방법 (2)

    Date2022.06.29 Category잡담 By댓글돌이 Views43 Votes1
    Read More
  16. No Image

    ㄴ제 아내임 (2)

    Date2022.06.29 Category잡담 By정상인 Views29 Votes0
    Read More
  17. No Image

    유게가 뒤질날이 올줄이야 (4)

    Date2022.06.29 Category잡담 By뉴뉴 Views69 Votes2
    Read More
  18. No Image

    일단 빨리 알람부터 고쳐봐 !!! (1)

    Date2022.06.29 Category잡담 By찌찌야 Views58 Votes1
    Read More
  19. No Image

    일단 양쪽 다 가입해야징 (1)

    Date2022.06.29 Category잡담 Byㅁㄴㅇㄹ Views70 Votes1
    Read More
  20. No Image

    #몬헌 pc판은 존버한다 (3)

    Date2022.06.29 Category잡담 By무나호시노바 Views39 Votes0
    Read More
  21. 우웅웅 (2)

    Date2022.06.29 Category잡담 By우웅☆말랑해! Views41 Votes0
    Read More
  22. No Image

    이거 글 보는 동안 아래 뜨는 글 목록 최신 목록으로 뜨면 편하겠다

    Date2022.06.29 Category잡담 ByClair-de-Lune Views59 Votes1
    Read More
  23. No Image

    ㄴ 자기 프사와 뜨거움 밤을 보냄

    Date2022.06.29 Category잡담 By빡빡이아저씨 Views59 Votes0
    Read More
  24. No Image

    근데.. 서명 어떻게 만드냐??

    Date2022.06.29 Category잡담 By오오조라스바루 Views54 Votes0
    Read More
목록
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 219 Next
/ 219