David Posin helps you land that next programming position by understanding important JavaScript fundamentals. JavaScript is a fun, powerful, and important language with a low barrier of entry. People from all kinds of backgrounds and careers find the…
看了几篇文章,放上来供参考 司徒正美的文章,Event Delegation Made Easy ------------------------------------------------------------------自己的理解加深印象----------------------------------------------------------------------------- What to use when For really small event handling…
事件委托 event delegation 一.概念: 假设我们有很多个子元素,每个元素被点击时都会触发相应事件,普通的做法是给每个子元素添加一个事件监听. 而,事件委托则是给它们的父元素添加一个事件监听器,子元素上没有任何事件监听.当子元素被点击时,这个点击事件冒泡到父元素上,然后父元素上绑定的事件监听来分析和处理这是哪个子元素被点击了. 二.例子1:一个ul及几个li: <ul id="parent-list" style="border:1px solid bla…
原文:https://medium.com/@florenceliang/javascript-event-delegation-and-event-target-vs-event-currenttarget-c9680c3a46d1 In this case, at the time you call console.log(e), there's a DOM element in the currentTarget property. But sometime later, that pro…
安卓面试题 Android interview questions 作者:韩梦飞沙 ‎2017‎年‎7‎月‎3‎日,‏‎14:52:44 1.      要做一个尽可能流畅的ListView,你平时在工作中如何进行优化的?  ①Item布局,层级越少越好,使用hierarchyview工具查看优化.  ②复用convertView  ③使用ViewHolder  ④item中有图片时,异步加载  ⑤快速滑动时,不加载图片  ⑥item中有图片时,应对图片进行适当压缩  ⑦实现数据的分页加载 2.…
原文 Node.js Interview Questions for 2017 什么是error-first callback? 如何避免无止境的callback? 什么是Promises? 用什么工具来保证代码的一致性风格? 为什么保持一致性风格很重要? When should you npm and when yarn? 什么是stub? 举个例子! 什么是test pyramid? 举个例子! 你喜欢哪个HTTP框架,为什么? 如何保护你的HTTP cookies 不遭受XSS攻击? 如何…
Bridge Pattern, Composite Pattern, Decorator Pattern, Facade Pattern, COR Pattern, Proxy Pattern, template Pattern, MVC. Updated with the explanation of Composite pattern, Decorator Pattern and Template Pattern. Design Pattern Interview Question - Pa…
Interpeter , Iterator , Mediator , Memento and Observer design patterns. (I) what is Interpreter pattern? (B) Can you explain iterator pattern? (A) Can you explain mediator pattern? (I) Can you explain memento pattern? (B) Can you explain observer pa…
简单的说,事件委托(event delegation)是在DOM上层(也就是在触发事件的元素的父元素上)定义事件的处理程序,而不是定义在触发事件的元素本身上. 首先我们来举这样一个例子:我有N个li元素,我想让点击过的li元素背景颜色都变为黄色.非常简单的一个例子是吧? 我们可以通过如下代码实现: var oBox = document.getElementById('box');var aLi = oBox.children;for(var i=0;i<aLi.length;i++){ add…
Explain "chaining". Chaining allows us to run multiple jQuery methods (on the same element) within a single statement.like this: $(selector).doA().doB().doC() Explain "deferreds". The Deferred object, introduced in jQuery 1.5, is a cha…