2012-04-09 1 views
0

내 코드 : 여기에iframe 하나의 부모와 다른 자식, jquery를 사용하여 자식 iframe 값을 가져 오려면 어떻게해야합니까? 여기

<div id="biography_name1"> 
    <iframe id="Array___Frame" src="some_value" height="600" frameborder="0" width="100%" scrolling="no" > 
     <html> 
       <head></head> 
       <body> 
        <iframe src="some_value"> 
         <div class="my_value"> GET THIS VALUE </div> 
        </iframe> 
       </body> 
     </html> 
    </iframe> 
</div> 

내가 jQuery를 사용하여 클래스 my_value 값을 얻을 싶어요. 내가 어떻게 할 수 있니?

+0

깨끗한 방법으로 해결할 수 있지만 [대부분의 질문에 대답해야합니다] (http://stackoverflow.com/questions/1654017/how-to-expose-iframes-dom-using) -jquery). – faino

답변

0

도움이된다면 upvote를 사용하여 답변을 수락하십시오! ;)

<iframe id='frameParent'> 
    <iframe id='frameChild'> 
     <div id="my_value">some text here</div> 
    </iframe> 
</iframe> 
<script> 
    var foo = $("#frameParent").contents().find("#frameChild").contents().find(".my_value").text(); 
    //NOW YOUR VALUE IS STORED IN THE VARIABLE CALLED FOO 
    //change '#' to '.' in last find statement  
</script> 

는 이제

+0

그게 작동하지 않습니다. 그것은 null 값을 제공합니다. –

+0

다시 보니 편집했습니다. 이제는 작동해야합니다 :) –

+0

나중에 이걸 시도했지만 하나의 프레임에서만 작동하지만 부모와 자식 프레임이 있으며 자식으로부터 가치를 얻고 싶습니다. 어떻게 얻을 수 있습니까? –

0
$(".my_value").text(); 

그렇게 할 것입니다 작동합니다.

관련 문제