$::Utility Methods<o:p></o:p>
---------------------------------------------------------------------------<o:p></o:p>
$(id | element) -> HTMLElement<o:p></o:p>
$((id | element)...) -> [HTMLElement...]<o:p></o:p>
If provided with a string, returns the element in the document with matching ID; otherwise returns the passed element. Takes in an arbitrary number of arguments. All elements returned by the function are extended with Prototype DOM extensions.<o:p></o:p>
---------------------------------------------------------------------------------------<o:p></o:p>
如果提供一个字符串给$()函数,例如 $(“div1”) 返回 id 为 div1的对象。<o:p></o:p>
如果传递的是一个对象。那么返回这个元素. $(obj) à obj<o:p></o:p>
如果传递一系列的id或者对象参数,所有的对象都会被返回,并以数组的形式。divs=$('div1','div2'); <o:p></o:p>
<o:p> </o:p>
不存在的ID返回null。<o:p></o:p>
如果传入的为多个id或者对象,如果遇到null对象,执行到遇到null为止将不再继续<o:p></o:p>
<o:p> </o:p>
如果页面包含2个id是相同的。返回第一个id符合的对象<o:p></o:p>
<o:p> </o:p>
$()函数返回的是Element对象。所以你可以使用Element.extend后的方法。例如可以使用$('itemId').hide();类似Element.hide('itemId');<o:p></o:p>
<o:p> </o:p>
当使用数组迭代器['item1', 'item2', 'item3'].each(Element.hide);执行某些操作时<o:p></o:p>
<o:p> </o:p>
$()函数可以让代码更优雅<o:p></o:p>
<o:p> </o:p>
$('item1', 'item2', 'item3').invoke('hide');<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
$$ :: Utility Methods<o:p></o:p>
--------------------------------------------------------------------------------------<o:p></o:p>
<o:p> </o:p>
$$(cssRule...) -> [HTMLElement...]<o:p></o:p>
<o:p> </o:p>
性能问题<o:p></o:p>
这里有些指导方针:<o:p></o:p>
1. 如果你要选择指定css类名的元素,可以使用document.getElementsByClassName() 这个Prototype的扩展方法<o:p></o:p>
2. if this search is constrained within a given container element, use the Element.getElementsByClassName() extension. 如果搜索对给定的容器元素是不舒服的,使用getElementsByClassName扩展方法<o:p></o:p>
分享到:
相关推荐
全面介绍PROTOTYPE1.5RC2 的使用
《Head First设计模式》(中文版)共有14章,每章都介绍了几个设计模式,完整地涵盖了四人组版本全部23个设计模式。前言先介绍这本书的用法;第1章到第11章陆续介绍的设计模式为Strategy、Observer、Decorator、...
《Head First设计模式》(中文版)共有14章,每章都介绍了几个设计模式,完整地涵盖了四人组版本全部23个设计模式。前言先介绍这本书的用法;第1章到第11章陆续介绍的设计模式为Strategy、Observer、Decorator、...
《Head First设计模式》(中文版)共有14章,每章都介绍了几个设计模式,完整地涵盖了四人组版本全部23个设计模式。前言先介绍这本书的用法;第1章到第11章陆续介绍的设计模式为Strategy、Observer、Decorator、...
《Head First设计模式》(中文版)共有14章,每章都介绍了几个设计模式,完整地涵盖了四人组版本全部23个设计模式。前言先介绍这本书的用法;第1章到第11章陆续介绍的设计模式为Strategy、Observer、Decorator、...
《Head First设计模式》(中文版)共有14章,每章都介绍了几个设计模式,完整地涵盖了四人组版本全部23个设计模式。前言先介绍这本书的用法;第1章到第11章陆续介绍的设计模式为Strategy、Observer、Decorator、...
至于第14章则很快地浏览尚未介绍的设计模式,包括Bridge、Builder、Chain of Responsibility、Flyweight、Interpreter、Mediator、Memento、Prototype、Visitor。第1章还介绍了四个OO基本概念(抽象、封装、继承、...
****JavaScript入门经典(第4版 英文版+第3版中文版 附JavaScript参考手册)****《JavaScript入门经典(第4版)》主要内容:·循序渐进介绍JavaScript基础知识,包括JavaScript的含义、原理和功能·介绍用于创建...
至于第14章则很快地浏览尚未介绍的设计模式,包括Bridge、Builder、Chain of Responsibility、Flyweight、Interpreter、Mediator、Memento、Prototype、Visitor。第1章还介绍了四个OO基本概念(抽象、封装、继承、...
《Head First设计模式》(中文版)共有14章,每章都介绍了几个设计模式,完整地涵盖了四人组版本全部23个设计模式。前言先介绍这本书的用法;第1章到第11章陆续介绍的设计模式为Strategy、Observer、Decorator、...
进行产品原型设计的软件工具也有很多种,我写的这个教程所介绍的Axure RP,是taobao、dangdang等国内大型网络公司的团队在推广使用的原型设计软件。同时,此软件也在产品经理圈子中广为流传。之所以Axure RP得到了...
中文叫做一次性控制器,也就像一次性筷子那样用完即丢 并不在Spring的Controller继承架构中,而是一个独立的接口定义 当映射的不是一个model 对象时很有用 Bean的作用域必须是prototype ,他们本身不是线程安全的
至于第14章则很快地浏览尚未介绍的设计模式,包括Bridge、Builder、Chain of Responsibility、Flyweight、Interpreter、Mediator、Memento、Prototype、Visitor。第1章还介绍了四个OO基本概念(抽象、封装、继承、...