手动触发文档就绪
是否可以手动重新触发已分配给文档 onready 事件的函数?
我知道这是一个尴尬的问题,而且很难解释这里的情况,但请假设我们有
$(document).ready(function() {
console.log('Hello World!');
}
没有办法在页面的某个地方以某种方式手动触发此事件?就像下面一样
<script type="text/javascript">
$(document).trigger('ready');
</script>
,但不幸的是这不起作用。有什么建议吗?
Is it possible to manually refire a function that has been assigned to document's onready event?
I know this is an awkward question, and it's kinda difficult to explain the situation here, but please suppose we have
$(document).ready(function() {
console.log('Hello World!');
}
Is there a way to manually trigger this event somehow somewhere in the page? like following
<script type="text/javascript">
$(document).trigger('ready');
</script>
But this doesn't work unfortunately. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么 ?难道你不能简单地
直接根据需要调用该函数吗
why ? cant you simply
then you can just call the function as needed directly