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

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

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

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

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

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

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

    화장실 들어갈때랑 나올 때 마음 다른거 (2)

    Date2024.01.10 Category잡담 By루돌프NDCT Views27 Votes0
    Read More
  6. No Image

    홀로라이브 공홈 복사 방지가 신박하네 (3)

    Date2022.07.12 Category잡담 By뉴리대장 Views73 Votes0
    Read More
  7. No Image

    혹시라도 저렴하게 사이트를 만들고 싶으면 오라클 클라우드 프리티어도 좋은 선택임. (4)

    Date2022.06.30 Category잡담 Bynana111 Views259 Votes2
    Read More
  8. 혹시나 궁금해서 newli.net 들어가봤는데 (3)

    Date2022.07.15 Category잡담 By뉴리대장 Views89 Votes0
    Read More
  9. No Image

    혹시 핫딜 게시판은 안생기나 (1)

    Date2022.06.30 Category잡담 By과자 Views79 Votes1
    Read More
  10. No Image

    혹시 있으신분 댓글 달아보샘 (12)

    Date2022.07.03 Category잡담 By뉴리대장 Views88 Votes0
    Read More
  11. No Image

    혹시 운영에 도움이 되고 싶다면 (5)

    Date2022.06.30 Category잡담 Bynewri Views212 Votes11
    Read More
  12. No Image

    혹시 여기도 동물 자지 규정 위반이야? (6)

    Date2022.06.30 Category잡담 By게으른뚱냥이 Views160 Votes0
    Read More
  13. No Image

    혹시 여기 미국사는 사람 있음? (2)

    Date2022.07.01 Category잡담 Bynewri Views78 Votes0
    Read More
  14. 혹시 여기 poe하던 애들도 넘어왔나? (6)

    Date2022.07.01 Category잡담 By중출은안된다 Views133 Votes3
    Read More
  15. No Image

    혹시 보조 관리자 신청 받으면 하겠음

    Date2022.06.30 Category잡담 By디젤펑크유저 Views71 Votes2
    Read More
  16. No Image

    혹시 나무위키 편집한 사람 있으면 (3)

    Date2022.07.01 Category잡담 Bynewri Views221 Votes7
    Read More
  17. No Image

    혹시 JS 잘하는 사람 공지 어떻게 숨기는지 좀 도와주셈 (8)

    Date2022.07.13 Category잡담 By뉴리대장 Views64 Votes0
    Read More
  18. No Image

    호을리씻 오염수 방류 (2)

    Date2023.08.27 Category잡담 ByIIIiiiIIiIIIi Views35 Votes0
    Read More
  19. No Image

    호오 루리웹이 3분할로 나눠졌네요 (4)

    Date2022.06.30 Category잡담 By시니아 Views146 Votes0
    Read More
  20. No Image

    호에에엥 신입이에요 (4)

    Date2022.06.30 Category잡담 By타치바나마리카 Views101 Votes1
    Read More
  21. 호불호 갈리는 점심식사 (2)

    Date2022.07.05 Category잡담 By할게없네 Views56 Votes1
    Read More
  22. 호불호 갈리는 식당 (3)

    Date2022.07.25 Category잡담 By할게없네 Views52 Votes1
    Read More
  23. No Image

    형탁이형 강등이 ㅍㄷㄹ 인거 레알임? (6)

    Date2022.06.30 Category잡담 By오샤osha Views169 Votes0
    Read More
  24. No Image

    형 부부와 어머니의 가족여행에 꼽사리 껴서 강릉으로 여행옴 (2)

    Date2024.02.09 Category잡담 ByIIIiiiIIiIIIi Views33 Votes2
    Read More
목록
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 218 Next
/ 218