Javascript JQuery链接 [英] Javascript JQuery chaining

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

问题描述

让我们说:

$("p")[0].innerHTML;

$("p").html();

在以上示例中,我们得到了相同的结果.因此,我想知道JQuery如何同时返回节点列表和自身以允许链接?

In the above examples, we have the same result. So I was wondering how can JQuery return both the nodelist and itself to allow chaining ?

推荐答案

所以我想知道JQuery如何同时返回节点列表和自身以允许链接?

So I was wondering how can JQuery return both the nodelist and itself to allow chaining ?

不是.

它仅返回自身(它是一个对象).

It only returns itself (which it an object).

该对象具有名为0的属性,该属性包含元素数组中的第一个元素.它还具有一个名为html的属性,其中包含一个函数.

That object has a property called 0 which contains the first element in the array of elements. It also has a property called html which contains a function.

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

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