Home  >  Article  >  Web Front-end  >  Use Jquery to get Dom elements in iframe pages

Use Jquery to get Dom elements in iframe pages

php中世界最好的语言
php中世界最好的语言Original
2018-04-24 14:50:543421browse

This time I will bring you how to use Jquery to get the Dom element in the iframe page, and use Jquery to get the Dom element in the iframe page. What are the precautions? The following is a practical case, one Get up and take a look.

Test page code:

<html> 
<head> 
<title>jquery方式,访问iframe页面dom元素</title> 
<meta name="Author" content="孙勤波"> 
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> 
<script type="text/javascript" src="http://s1.bdstatic.com/r/www/cache/static/jquery/jquery-1.10.2.min_f2fb5194.js"></script> 
<script type="text/javascript"> 
function getIframeDom(){ 
// 获取iframe的test元素 
var test = $("#frame_1").contents().find("#test"); 
alert(test.html()) 
} 
</script> 
</head> 
<body> 
<iframe src="file:///C:/Users/SUN/AppData/Local/Temp/non9C34.htm" id="frame_1"></iframe> 
<br /> 
<a href="javascript:getIframeDom();">获取iframe 页面test元素内容</a> 
</body> 
</html>
test.html Page code

<html> <head> <title>iframe页面a.html</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> </head> <body> <p id="test">我是测试页面test</p> </body> </html>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related matters on the php Chinese website article!

Recommended reading:

A collection of jquery methods for traversing and filtering arrays and json objects

##Detailed explanation of the steps for jquery to remove selected values ​​from an array

The above is the detailed content of Use Jquery to get Dom elements in iframe pages. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn