Mor*_*ang 2 javascript jquery jquery-mobile
我有一个关于.live触摸事件的简单问题.我想要做的是当用户点击/触摸页面的主体(容器)时,refreshCanvas调用该函数.然而,这似乎对我没有用.
JavaScript的:
<script type="text/javascript">
function refreshCanvas () {
var code = document.getElementById('iframe');
code.src = code.src; // that is the essence here
}
setInterval(refreshIframe1, 20000);
function refreshIframe1() {
$("#iframe")[0].src = $("#iframe")[0].src;
}
$('#container').live("tap", function() {
refreshCanvas();
});
</script>
Run Code Online (Sandbox Code Playgroud)
HTML:
<a href="javascript:refreshCanvas()"><img src="data/refresh.jpg"></a>
<div id="container">
<iframe id="iframe" src="data/canvas.html" z-index: 0; style="border: 0; position:absolute; top:0; left:0; right:0; bottom:0; width:100%; height:100%"></iframe>
</div>
Run Code Online (Sandbox Code Playgroud)
如果您使用的是最新版本的jQuery(1.9),他们已经.live()完全删除了绑定事件的方法,并建议您使用/学习该.on()方法.
$('.something').live('event', function(){...});
Run Code Online (Sandbox Code Playgroud)
相当于
$(document).on('event', '.something', function(){...});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1063 次 |
| 最近记录: |