본문 바로가기
조회 수 65 추천 수 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뉴리대장 Views862 Votes5
    read more
  2. No Image notice

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

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

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

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

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

    Date2022.06.29 Category공지 By뉴리대장 Views1806 Votes19
    read more
  5. No Image

    진짜 .net 도에민에 짧은 도메인 은근 많네

    Date2022.06.29 Bynewri Views78 Votes0
    Read More
  6. No Image

    테스트 테스트 (1)

    Date2022.06.29 By쿠르스와로 Views70 Votes0
    Read More
  7. No Image

    버그제보 (1)

    Date2022.06.29 Byntr충 Views48 Votes0
    Read More
  8. 와!

    Date2022.06.29 By푸라운 Views71 Votes0
    Read More
  9. No Image

    누리웹은 어떻게 뽑힐지 궁금함

    Date2022.06.29 Bynewri Views84 Votes0
    Read More
  10. 카아아악 투엣

    Date2022.06.29 By코리안아사나기 Views60 Votes0
    Read More
  11. No Image

    근데 누리웹은 아직도 안열렸네 (2)

    Date2022.06.29 Bynewri Views120 Votes0
    Read More
  12. 응애

    Date2022.06.29 By녹슨닻 Views45 Votes0
    Read More
  13. No Image

    자꾸 오타를 내내

    Date2022.06.29 Bynewri Views45 Votes0
    Read More
  14. 안녕하세요.

    Date2022.06.29 By할게없네 Views45 Votes0
    Read More
  15. No Image

    대충 완성된 것 같으니까 밥이나 먹고와야겠다

    Date2022.06.29 Bynewri Views56 Votes0
    Read More
  16. No Image

    괜찮은데 갤러리 스타일 옵션은 (1)

    Date2022.06.29 By미니오리 Views88 Votes0
    Read More
  17. No Image

    흥미롭네요 (2)

    Date2022.06.29 By이잉 Views45 Votes0
    Read More
  18. No Image

    섻스

    Date2022.06.29 By무요 Views44 Votes0
    Read More
  19. No Image

    유머는

    Date2022.06.29 By관리-03 Views74 Votes0
    Read More
  20. No Image

    새 방주군요

    Date2022.06.29 By이마이아사미 Views48 Votes0
    Read More
  21. 여기로 이주 하면 되는 각 이 냐 ? (2)

    Date2022.06.29 ByOozoraSubaru Views87 Votes0
    Read More
  22. 으윽 ui가 너무 작아 (2)

    Date2022.06.29 By스마일 Views85 Votes0
    Read More
  23. No Image

    뭐여 익명도 되나보네 (1)

    Date2022.06.29 By으앙어둠 Views61 Votes0
    Read More
  24. No Image

    익명도 된다고?

    Date2022.06.29 By이시무라 Views60 Votes0
    Read More
목록
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 426 Next
/ 426