$('iframe')。ready()方法在jQuery中如何工作?
这是一个示例,其中iframe的大小大于页面的大小。每当使用jQuery加载iframe时,我们都会滚动到页面顶部-
示例
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$('iframe').ready(function(){
$(window).scrollTop(0);
});
});
});
</script>
</head>
<body>
<iframe frameborder="2" height="900" id="iframe" align="top" src="https://www.qries.com" width="900" ></iframe><br>
<button>Loop through each image</button>
</body>
</html>