Warning: Undefined array key "mobile_dir" in /home/kagla/new-sir/old/common.php on line 315
getElementById한값을 a태그 안에 href 값을중 원하는값으로 치환하는 방법

getElementById한값을 a태그 안에 href 값을중 원하는값으로 치환하는 방법

getElementById한값을 a태그 안에 href 값을중 원하는값으로 치환하는 방법

QA

getElementById한값을 a태그 안에 href 값을중 원하는값으로 치환하는 방법

답변 1

본문


<script>
var element = document.getElementById(this.frame.getElementsByTagName('dl')[0]); 
	console.log(element); // 출력1 
 
</script>

 

우선 출력1을 보시면 

 


출력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


<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>
 
답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 129,406
© SIRSOFT
현재 페이지 제일 처음으로