채택완료
getElementById한값을 a태그 안에 href 값을중 원하는값으로 치환하는 방법
Copy
<script>var element = document.getElementById(this.frame.getElementsByTagName('dl')[0]); console.log(element); // 출력1 </script>
우선 출력1을 보시면
Copy
출력1<di class= "main_items"><dt class="p_img"> <a href="../product/view.html?pid=16&cate1=53&cate2=80&no=80"> <img src="../PEG/product/80/14524961206291.jpg"> </a></dt> <dd class="p_info"><p class="p_name"> <a href="../product/view.html?pid=16&cate1=53&cate2=80&no=80" class="con_tit"><p class="p_text"><a href="../product/view.html?pid=16&cate1=53&cate2=80&no=80"></a></p></dd></di>
이렇게 출력 되는데요 여기 href들 공통적으로 view -> list로 변경하는 방법 알고 싶습니다 ㅠ,ㅠ
답변 1개 / 댓글 1개
채택된 답변
+20 포인트
2016-01-20 (수) 19:49:44
Copy
<script type="text/javascript">$(function() { $("dl.main_items a").each(function() { var o_href = $(this).attr("href"); var n_href = o_href.replace(/view.html/g, "list.html"); $(this).attr("href", n_href); });});</script>
답변에 대한 댓글 1개
답변을 작성하려면 로그인이 필요합니다.