没有链的jQuery吗? [英] jQuery without chain?

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

问题描述

我知道可以用更多JavaScript之类的语法而不是整个链来编写 jQuery 东西(很棒).很难找到一部能为那些希望使用较少可链接脚本的人提供理解的教程,因此在哪里可以找到任何类型的教程?

I know it's possible to write jQuery in more JavaScript like syntax rather than the all chain stuff (which is great). It's hard to find a piece of tutorial that provide an understanding for people who want to use less chain-able script, so where I can find any type of tutorial(s)?

虽然链条还不错,但要有效就需要学习曲线.高效的.我有一些JavaScript方面的经验,因此,如果我可以重用我现有的知识(也可以在严格而快速的工作环境中懒惰地学习新知识),那将是很棒的.

While the chain was not bad, it requires a learning curve for being effective & efficient. I have some experience in JavaScript so it would be great if I could re-use my existing knowledge (a.k.a laziness to learn something new on strict and fast moving work environment).

PS:我通常使用链较少的框架,例如Adobe Spry框架(已停用,可悲的是),所以我希望可以找到一些类似的方法在jQuery上编写代码.

PS: I usually use a less chain framework such as Adobe Spry Framework (dead, sadly), so I hope I could finf some similar approach in writing code on jQuery.

推荐答案

由于链的每个部分都返回一个jQuery对象,因此您可以将链拆分成单独的部分.

Since each part of the chain returns a jQuery object, you can break the chain up into separate pieces.

所以,这个...

$("<div>inner</div>")
    .appendTo("<div>outer</div>")
    .appendTo("body");

与以下内容完全相同:

var myDiv = $("<div>inner</div>");
myDiv.appendTo("<div>outer</div>");
myDiv.appendTo("body");

但是请相信我,一旦您习惯了它,它将成为第二天性.查看本文以了解一些内容更多建议...

But believe me, once you get used to it, it will become second nature. Check out this article for some more advice...

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

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