Home > Web Front-end > JS Tutorial > body text

Jquery gets the Dom element in the iframe page (with code)

php中世界最好的语言
Release: 2018-04-26 15:25:17
Original
3807 people have browsed it

This time I will bring you Jquery Get the Dom element in the iframe page (with code), what are the precautions for Jquery to get the Dom element in the iframe page, the following is a practical case , let’s take a look.

<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.bd
static
.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>
Copy after login

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>
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

jQuery cross-domain operation DOM method in iframe

How jQuery calculates the width and height of the iframe window

The above is the detailed content of Jquery gets the Dom element in the iframe page (with code). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!