jQuery:仅运行一次 [英] jQuery: run only once

查看:101
本文介绍了jQuery:仅运行一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我有一个fancybox.如果?mode = new

Yes i have an fancybox. It auto opens if ?mode=new

在?mode = new上发生的是:

What happens on ?mode=new is:

<script>
$(document).ready(function(){
$('#newPM').click();
});
</script> 

打开正常.但是,当您单击该元素时,该元素将保持关闭/打开状态,因为这已激活.那我怎么只能运行一次呢?

It opens fine. But when you then click on the element, it keeps closing/open, because this is activated. So how can i only run this once?

推荐答案

您是说它不断打开和关闭fancybox吗?您可以

Do you mean it keeps opening and closing the fancybox? You can do

$("#newPM").unbind("click"); 

这将删除onclick事件,使其不再被触发.

This will remove the onclick event so it doesn't get triggered anymore.

这篇关于jQuery:仅运行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆