本文介绍了jQuery中$和$()之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能解释一下jquery中$$()之间的区别吗?

Could someone take the effort to explain me the difference between $ and $() in jquery?

我知道$()$jQuery()的简写形式,它接受任何DOM元素并将其转换为jQuery对象.

I know $() is shorthand form of $jQuery() which takes any DOM element and turns it into a jQuery object.

但是我不确定什么是$,它与$()有何不同.请赐教.

But what I am not sure of is what is $ and how different is it from $(). Kindly enlighten me.

感谢堆,柴坦亚

推荐答案

$函数,可以称为-$().

$()的行为在很大程度上取决于所提供的参数,尽管下面的所有示例都会返回一个jQuery对象.它可以:

The behaviour of $() varies immensely depending on the parameters supplied, although all examples below will return a jQuery object. It can:

  1. 注册document.ready处理程序-$(myfunc)
  2. 充当选择器 -
  3. 构造元素-$('<div>')
  4. 返回一个空对象-$()
  1. register a document.ready handler - $(myfunc)
  2. act as a selector - $('#myid')
  3. construct elements - $('<div>')
  4. return an empty object - $()

$也是一个对象,其中包含各种实用程序功能$.each,例如该对象的 properties .在这种情况下,这些功能就像 namespace 一样.

$ is also an object that contains various utility functions $.each, etc as properties of that object. In this context, it acts like a namespace for those functions.

这篇关于jQuery中$和$()之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 07:32