我被困在这里
set -o errexit
JS 2ND更新:
ssh
当我点击图片时,有人可以帮我创建de <img src="img/server1.png" class="img-thumbnail servidor" data-url="https://google.com/"/>
<div id="servidores-player">
<iframe src="" id="player"></iframe>
<div class="servidor-info">
<div class="container">HD</div>
标记吗?并在加载之前跳转到iframe元素?
我已经更新了codeuntil我正在收到错误的部分
答案 0 :(得分:1)
$(function() {
$(".servidor").on("click", function() {
$('#servidores-bg').hide(); // IDs must be unique
$("#player").replaceWith(
$("<iframe/>", {
id: "player",
src: $(this).data("url")
})
);
$('#servidores-player .servidor-info').show();
var distance = $('#servidores-player iframe').offset().top;
$('html,body').animate({
scrollTop: distance
}, 1500);
$('#servidores-player').show();
});
});
function mostrarServidores() {
var $inser = $('#inserido-utilizador');
if ($inser.length) {
$inser.toggle();
$('#servidores-bg').toggle($inser.is(":visible"));
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<img src="img/server1.png" class="img-thumbnail servidor" data-url="http://api.jquery.com/replacewith/" />
<img src="img/server1.png" class="img-thumbnail servidor" data-url="http://api.jquery.com/toggle/" />
<div id="servidores-player">
<iframe src="" id="player"></iframe>
<div class="servidor-info">
<div class="container">
HD
</div>
</div>
</div>
答案 1 :(得分:0)
如果要设置iframe src,请使用:
$('#player').attr('src', $(this).data('url'));
滚动到它:
$('html, body').animate({scrollTop: $("#player").offset().top}, 2000);
-