채택완료

버튼클릭후 버튼색상변경

<input type="button" class="bt1" id="bt" value="ㅁ" onclick="location.href='index.php?sc=<?php echo "ㅁ" ?>'"/>
        <input type="button" class="bt2" id="bt" value="ㅠ"  onclick="location.href='index.php?sc=<?php echo "ㅠ" ?>'" />
        <input type="ㅊ" class="bt3" id="bt" value="ㅊ"  onclick="location.href='index.php?sc=<?php echo "상장예정주" ?>'" />
        <input type="button" class="bt4" id="bt" value="ㅇ"  onclick="location.href='bbs/popular_news.php'" />

이렇게 버튼클릭후 페이지 이동하면 어떻게 이동한 페이지에서 버튼에 색상을 다르게 변경하죠?

css부분 어떻게 해야되는지 모르겠어요ㅠ

#bt:hover {
        background-color: rgba(0, 0, 100, 0.5);
    }

누를때 생상변경은 알겠는데 페이지이동후 유지를 어떻게 해야될까요..

|

답변 2개

채택된 답변
+20 포인트

별도 백쪽에 쿠키처리안되어있으면
css만으로는 어렵습니다

세션 스토리지에 어떤 버튼을 선택했는지 저장하고 이동한 페이지에서 세션 스토리지에 담긴 값에 따라 버튼에 클래스를 주든 인라인으로 css를 적용하든 하면 되지 싶습니다.

답변을 작성하려면 로그인이 필요합니다.