- 添加 jQuery 链接
- 为图像和 iframe 添加 id
- 添加脚本块(下)
我制作了工作样本:http: //jsbin.com/acocil/4/
<html>
<head>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.8.2.min.js"></script>
</head>
<body>
<div>
<img id="image1" href="#" src="FirstImage.jpg" alt="Hover to reveal second Image"/>
</div>
<div>
<iframe id="frame1" name="IFRAME" src="text.html"></iframe>
</div>
<script>
$(document).ready(function() {
$('#image1').mouseover(function(){
$('#frame1').attr('src','SecondImage.jpg');
}).mouseout(function(){
$('#frame1').attr('src','text.html');
});
});
</script>
</body>
</html>
对于两帧:
<iframe id="frame1" alt="Hover to reveal second Image"></iframe>
<iframe id="frame2" src="https://www.google.ru/images/srpr/logo3w.png"></iframe>
<script>
$(document).ready(function() {
$('#frame1')[0].contentDocument.write('<img id="image1" src="http://l.yimg.com/a/i/us/msg/site/9/sp/ic_biggrin.gif"/>');
$('#frame1').contents().find('img').mouseover(function(){
$('#frame2').attr('src','https://www.google.ru/images/srpr/logo3w.png');
}).mouseout(function(){
$('#frame2').attr('src','http://lostfilm.tv');
});
});
</script>