在讨论之前,先约定好定义变量的风格。
如果获取的对象是jQuery对象,那么在变量前加上$,例如:
如果获取的是DOM对象,则定义如下:
2、通过get(index)方法得到相应的DOM对象。
对于一个DOM对象,只需要用$()把DOM对象包装起来,就可以获得一个jQuery对象了,方式为$(DOM对象)。
总结:
一、jQuery方法里的get方法事实上是获得Dom元素($(this).get(0)与$(this)[0])
二、而jQuery方法里的eq、first、last等方法都是返回的Jquery对象
三、DOM对象才能使用DOM中的方法,jQuery对象不可以使用DOM中的方法。jQuery对象提供了一套更加完善的工具用于操作DOM。
The difference between static web pages and dynamic web pages
What is the difference between 4g and 5g mobile phones?
The difference between k8s and docker
The difference between JD.com's self-operated flagship store and its official flagship store
How to use insert statement in mysql
What does Xiaohongshu do?
What does it mean when a message has been sent but rejected by the other party?
What are artificial intelligence technologies?