gpt4 book ai didi

javascript - Backbone.js View 中的 $el 和 el 有什么区别?

转载 作者:IT王子 更新时间:2023-10-29 02:55:14 25 4
gpt4 key购买 nike

你能说出 Backbone.js View 中 $elel 的区别吗?

最佳答案

"el"  is HTMLElement
"$el" is jQuery

假设你这样做

var myel = this.el; // here what you have is the html element, 
//you will be able to access(read/modify) the html
//properties of this element,

有了这个

var my$el = this.$el; // you will have the element but 
//with all of the functions that jQuery provides like,
//hide,show etc, its the equivalent of $('#myel').show();
//$('#myel').hide(); so this.$el keeps a reference to your
//element so you don't need to traverse the DOM to find the
// element every time you use it. with the performance benefits
//that this implies.

一个是html元素,一个是元素的jQuery对象。

关于javascript - Backbone.js View 中的 $el 和 el 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16646526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com