Home  >  Q&A  >  body text

jq是如何做到可以多次调用某方法的?

RT,例如 $('xxx').find('xxx').find('xxx').find('xxx')...
最好能贴个精简版的DOME研究几番

phpcn_u251phpcn_u2512693 days ago940

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 00:39:59

    How does jq make it possible to call a method multiple times? -PHP Chinese website Q&A-How can jq call a method multiple times? -PHP Chinese website Q&A

    Let’s take a look and learn.

    reply
    0
  • 阿神

    阿神2017-03-02 13:36:31

    方法执行完再返回jQuery就行了,这个叫jQuery的链式操作。
    优点有一下:
    代码更精简。链式操作能大大精简代码量,多项操作一行代码一气呵成,搞定;
    优化性能。使用链式操作,所有操作代码共享一个jQuery对象,省去了逐步查询DOM元素的性能损耗。

    reply
    0
  • Cancelreply