jQuery准备好了,它总是需要吗? [英] jQuery ready, is it always needed?

查看:47
本文介绍了jQuery准备好了,它总是需要吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于我的问题:验证动态添加的控件

我们应该总是在javascripts上使用ready函数吗?

Should we always use the ready function on javascripts?

推荐答案

一个人应该只操纵DOM保证这样的操作有效并且行为定义明确

延迟执行直到文档就绪事件(jQuery) .ready)确保DOM完整。但是,根据浏览器和上下文,很可能不需要它 - 不是我喜欢的东西(它还涉及更多思考并使代码更依赖于HTML /代码顺序)。

Delaying execution until the "document ready event" (jQuery.ready) ensures the DOM is "complete". However, depending upon browser and context, it is quite possible it is not needed -- not something I like to bet on (it also involves more thinking and makes code more dependent upon the HTML/code order).

快乐编码。

这篇关于jQuery准备好了,它总是需要吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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