What's the difference between: $(this.el).html and this.$el.html

前端 未结 6 1017
说谎
说谎 2020-12-13 02:26

What\'s the difference between:

$(this.el).html

and

this.$el.html

Reading a few backbone examples and so

6条回答
  •  萌比男神i
    2020-12-13 02:41

    The two are essentially* equivalent, with $el being a cached version of the jQuery or Zepto objects el, the reason why you see examples using $(this.el) is because it was only added in a later release of backbone.js (0.9.0).

    *Technically as Chris Baker points out $(this.el) will (probably) create a new jQuery/Zepto object each time you call it while this.$el will reference the same one each time.

提交回复
热议问题