2017-03-24 1 views
-1

jQuery를 사용 중이고 테이블 행을 다른 대상 프레임에 연결하려고합니다.테이블 행을 다른 프레임에 연결하는 방법은 무엇입니까?

테이블 행 :

<tr data-href="home.html" target="content"><td><h3><center>Home</h3></td></tr> 

사용 :

jQuery(document).ready(function() { 
    $("tr").on({ 
     click: function() { 
      window.location = $(this).data("href"); 
      $(this).css("background-color","blue"); 
     } 
    }); 
}); 

는 있지만, 동일한 프레임 내에서 링크를 연다.

답변

0

속성을 설정하면 특정 프레임이 아닌 현재 창의 위치가 변경됩니다.

jQuery(document).ready(function() { 
 
    $("tr").on({ 
 
    click: function() { 
 
     $("iframe[name='content']").attr("src", $(this).data("href")); 
 
     $(this).css("background-color", "blue"); 
 
    } 
 
    }) 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<table> 
 
    <tr data-href="http://stackoverflow.com" target="content"> 
 
    <td> 
 
     <h3> 
 
     <center>Home</centre> 
 
     </h3> 
 
    </td> 
 
    </tr> 
 
</table> 
 
<iframe name="content"></iframe>

:

당신이 당신의 click 기능을 변경하는 "내용", 당신이해야 할 설정 name 속성과 <iframe>을 가정
관련 문제