首先执行的Javascript或jquery [英] Javascript or jquery which is executed first

查看:64
本文介绍了首先执行的Javascript或jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个aspx页面...我有一个javascript函数,并在页面加载时使用Jquery.

I have an aspx page... i have a javascript function and Jquery on page load. Which one is executed first and Why?

推荐答案

jQuery是一个库. jQuery是用JavaScript编写的,当您使用jQuery编写代码时,就是在编写JavaScript.因此它不是比JavaScript更快".
但是低质量的javascript代码在大多数情况下会比jQuery慢.
jQuery is a library. jQuery is written in JavaScript, and when you write code with jQuery, you''re writing JavaScript. So it''s not "faster than JavaScript".
But low quality javascript codes will be slower than jQuery for most cases.


正如Hasan337所提到的,jQuery只是包装在对象中的javascript函数的负载!

使用javascript,执行顺序可能很重要,并且参考文件的位置很重要.例如,在引用jQuery源文件之前,您不能调用jQuery函数-该函数尚未定义.

无论如何,请看一下这份文档,它描述了jQuery
As mentioned by Hasan337, jQuery is just a load of javascript functions wrapped up in an object!

With javascript, the order of execution can be important & where you reference files are important. For example, you couldn''t call a jQuery function *before* you''ve referenced the jQuery source file - the function wouldn''t be defined yet.

Have a look at this document anyway, which describes the jQuery


(document).ready()

http://www.learningjquery.com/2006/09/introducing-document-ready [ ^ ]

与body.onLoad相比,该文档指出...

...此外,它会在窗口加载时触发这些事件,这使我想到了
(document).ready()

http://www.learningjquery.com/2006/09/introducing-document-ready[^]

Compared to body.onLoad, the document states...

...Also, it triggers those events when the window loads, which leads me to another advantage of


这篇关于首先执行的Javascript或jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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