how to access the “id',”name" etc. of Loaded URL in iframe from the HTML file using Jquery

how to access the “id',”name" etc. of Loaded URL in iframe from the HTML file using Jquery

 

I have an Iframe.html file :

<body onload="alert('frame 1 loaded');"> 
<div> This is frame 1 content </div> 
<a id="a1" href="Sample.html"> click</a>  
</body> 

Sample.html

<body> 
<ul id="list1"> 
<li name="one">one</li> 
<li name="two">two</li> 
</ul> 

And I calling the iframe form test.html file :

   <script type="text/javascript" src="jquery-1.5.1.min.js"></script> 
   
<script type="text/javascript"> 
    $
(document).ready(function() { 
   
var i=10; 
    $
("#frame1").ready(function () {  
 
    $

('#frame1').contents().find('#a1').click(function() { 
       alert
("Hello"); 
      $
('#frame1').attr('src', $('#frame1').contents().find('#a1').attr("href")); 
      $
('#frame1').load(); 
   
}); 
    $
('#frame1').contents().find('#a1').click();  
</script> 
   
</head> 
   
<body onload="handleMainOnload();"> 
       
<!--iframe id="frame1" src="about:blank"/--> 
       
<iframe id="frame1" src="iframe.html"/> 
   
</body> 

Now I tried using the content of URL loaded in iframe i.e. Sample.html in test.html as follows :

$('#frame1').contents().find('#list1 li[name=one]').click(function() { 
   alert
(" Clicking list...."); 
}); 
 
$

('#frame1').contents().find('#list1 li[name=one]').click();  

But this doesn't work.. Can you please tell me From Test.html how to access Sample.html file content like(id,name,class etc.) which is loaded in iframe.html using JQuery. Please help.

- Thanks