Home > Web Front-end > JS Tutorial > jquery method to get the value of the tag under the body in the same source iframe_jquery

jquery method to get the value of the tag under the body in the same source iframe_jquery

WBOY
Release: 2016-05-16 16:35:15
Original
1314 people have browsed it

test.html

Html code

<!DOCTYPE HTML> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>jquery</title> 
<style type="text/css"> 
</style> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
<script type="text/javascript"> 
$(document).ready(function (){ 
$("#show").click(function (){ 
var iframeObj = $(window.frames["iframe_name"].document); 
alert(iframeObj.find("#un").val()); 

}); 

}); 
</script> 
</head> 
<body> 
<input type="button" id="show" value="show" /> 
<iframe id="iframe_id" name="iframe_name" src="http://localhost/test/login.html"></iframe> 
</body> 
</html>
Copy after login

login.html

Html code

<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>登录页面</title> 
</head> 
<body> 
<form method="POST" action="#"> 
用户名:<input id="un" type="text" name="username" value="123d" /> 
密 码:<input type="text" name="password"/> 
<input type="submit" value="提交"> 
</form> 
</body> 
</html>
Copy after login

Note: must come from the same source

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