简而言之,我有一个页面,其中内容正在加载jquery load().问题是当我想选择时.
$('a.selected_class').click(function(e){
alert('alert');
e.preventDefault();
});
Run Code Online (Sandbox Code Playgroud)
(内部文档就绪)在第一页上工作,但在任何后续页面(使用$(this).load(url);加载到div)中,选择器停止工作.
有小费吗?
我有一个显示图像的html页面.它应该延迟,更改为视频,然后在视频播放后,更改回图像.这是我正在使用的JavaScript:
<script type="text/javascript">
function playVideo(){
var str='**html of the video object**';
document.open();
document.write(str);
document.close();
}
function backToImage(){
var str='**html of the image**';
document.open();
document.write(str);
document.close();
}
setTimeout("playVideo()",1000);
setTimeout("backToImage()",3000);
</script>
Run Code Online (Sandbox Code Playgroud)
此JavaScript可在Chrome和Safari中使用.它主要在IE中工作(第二次超时不起作用,但我刚刚发现了这一点).它在Firefox中根本不起作用.没有延迟,视频只是开始播放,我从来没有看到图像; 之前或之后.
对此的任何想法都会很棒.
编辑:所以似乎应该责备document.write.改变标题以反映这一点.
如果我的原始问题不清楚,我要找的是用视频替换图像,然后用图像替换视频.这都是在iframe中加载的,所以我需要使用document.write(或类似的东西)来实际更改 html.