홈페이지

html 강제로 링크 및 css 수정하기

초코몽몽 2025. 3. 19. 10:04
728x90

<!-- 기존 HTML 소스 -->
<ul class="nav">
    <li><a href="/mart_main.asp?smode=martmain">교수/강좌안내</a></li>
    <li><a href="/Free/">무료강의</a></li>
    <li><a href="/etc/">기타</a></li>
</ul>

<!-- 추가할 CSS와 JS -->
<style>
    .modified-link {
        color: #000; /* 원하는 색상으로 변경 가능 */
        text-decoration: none; /* 필요에 따라 스타일 조정 */
    }
</style>

<script>
    // DOM이 로드된 후 실행
    document.addEventListener('DOMContentLoaded', function() {
        // 무료강의 링크를 찾아서 수정
        const freeLectureLink = document.querySelector('a[href="/Free/"]');
        if (freeLectureLink) {
            // 텍스트 변경
            freeLectureLink.textContent = '무료강의는 공지사항으로';
            // 링크 주소 변경 (예: /notice/로 변경)
            freeLectureLink.setAttribute('href', '/notice/');
            // 클래스 추가 (스타일 적용을 위해)
            freeLectureLink.classList.add('modified-link');
        }
    });
</script>