看来,当我将它放入与<script></script>
的HTML中时,JavaScript不会运行,但它对于在线工具正常工作。当图像被点击时,JavaScript应该能够用视频替换图像。我怎样才能添加到HTML?HTML不能与JavaScript一起工作
它在使用这个在线工具 http://jsfiddle.net/odoycz6n/3/
HTML
<img src="http://www.whatever9495.com/template/damei_d21/image/logo.png" data-video="https://drive.google.com/file/d/0Bwbk-P9knHkGa21vSzYzMFl6YXM/preview">
的JavaScript
$('img').click(function() {
video = '<iframe src="' + $(this).attr('data-video') + '" width="715" height="480" frameborder="0" allowfullscreen=""></iframe>';
$(this).replaceWith(video);
});
你是否包括jQuery的?你如何将你的脚本添加到你的HTML? –
java与JavaScript无关。 – epascarello
我的猜测,如果你不像小提琴那样加载你的代码。 – epascarello