자바스크립트 or php 질문드립니다~ 채택완료
one9601
4년 전
조회 2,234
저는 해당 요소에 active가 있으면, 원하는 코드를 노출시키고 싶습니다
</p>
<p> </p>
<p> <button class="first_main_tablinks main_tablinks active" onclick="openCity(event, 'London')">공지사항</button></p>
<p> <button class="second_main_tablinks main_tablinks" onclick="openCity(event, 'Paris')">재단소식</button></p>
<p> <button class="third_main_tablinks main_tablinks" onclick="openCity(event, 'Tokyo')">게시판</button></p>
<p> <script></p>
<p> if($(".first_main_tablinks").hasClass("active")){</p>
<p> document.write("<a href='<a href="https://www.naver.com/' class='go_notice'><p>더보기+</p></a>");" target="_blank" rel="noopener noreferrer">https://www.naver.com/' class='go_notice'><p>더보기+</p></a>");</a></p>
<p> } else if ($(".second_main_tablinks").hasClass("active")){</p>
<p> document.write("<a href='<a href="https://www.daum.net/' class='go_notice'><p>더보기+</p></a>");" target="_blank" rel="noopener noreferrer">https://www.daum.net/' class='go_notice'><p>더보기+</p></a>");</a></p>
<p> } else if ($(".third_main_tablinks").hasClass("active")){</p>
<p> document.write("<a href='<a href="https://www.google.co.kr/' class='go_notice'><p>더보기+</p></a>");" target="_blank" rel="noopener noreferrer">https://www.google.co.kr/' class='go_notice'><p>더보기+</p></a>");</a></p>
<p> }</p>
<p> </script></p>
<p> </p>
<p>
그래서 제가 자바스크립트로 시도한 것은..
if($(".first_main_tablinks").hasClass("active")){
document.write("https://www.naver.com/' class='go_notice'> 더보기+
} else if ($(".second_main_tablinks").hasClass("active")){
document.write("https://www.daum.net/' class='go_notice'> 더보기+
} else if ($(".third_main_tablinks").hasClass("active")){
document.write("https://www.google.co.kr/' class='go_notice'> 더보기+
}
이것 입니다..
부끄럽지만.. 생각해낸 방법이 클래스를 하나하나 추가해서 active를 갖고있으면 a태그의 href가 바뀌는 느낌으로 해봤습니다
$(function()) 으로 묶으니까 페이지가 사라지고 더보기+만 나타나더라구요??
php나 script나 방법이 있나요~?
댓글을 작성하려면 로그인이 필요합니다.
답변 2개
답변을 작성하려면 로그인이 필요합니다.
로그인