2007-11-11

prototype中文介绍

关键字: prototype
 

$::Utility Methods

---------------------------------------------------------------------------

$(id | element) -> HTMLElement

$((id | element)...) -> [HTMLElement...]

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.

---------------------------------------------------------------------------------------

如果提供一个字符串给$()函数,例如 $(“div1”) 返回 id div1的对象。

如果传递的是一个对象。那么返回这个元素. $(obj) à obj

如果传递一系列的id或者对象参数,所有的对象都会被返回,并以数组的形式。divs=$('div1','div2');

 

不存在的ID返回null

如果传入的为多个id或者对象,如果遇到null对象,执行到遇到null为止将不再继续

 

如果页面包含2id是相同的。返回第一个id符合的对象

 

$()函数返回的是Element对象。所以你可以使用Element.extend后的方法。例如可以使用$('itemId').hide();类似Element.hide('itemId');

 

当使用数组迭代器['item1''item2''item3'].each(Element.hide);执行某些操作时

 

$()函数可以让代码更优雅

 

$('item1''item2''item3').invoke('hide');

 

 

 

 

 

 

 

$$ :: Utility Methods

--------------------------------------------------------------------------------------

 

$$(cssRule...) -> [HTMLElement...]

 

性能问题

这里有些指导方针:

1.     如果你要选择指定css类名的元素,可以使用document.getElementsByClassName() 这个Prototype的扩展方法

2.     if this search is constrained within a given container element, use the Element.getElementsByClassName() extension. 如果搜索对给定的容器元素是不舒服的,使用getElementsByClassName扩展方法

评论
发表评论

您还没有登录,请登录后发表评论

wutao8818
搜索本博客
我的相册
6b189252-4523-3f66-9b60-b4c688770fec-thumb
电信搞什么
共 12 张
最近加入圈子
存档
最新评论
  • 部署django记
    不知道。现在自己有服务器了。就不用虚拟主机了。
    -- by wutao8818
  • 部署django记
    有没有其他python虚拟主机服务的介绍
    -- by jimichan
  • 部署django记
    我现在已经不用他们的主机了。服务质量太差。有些东西问他们觉得不是他们的事情就不管 ...
    -- by wutao8818
  • 部署django记
    请问,那些静态文件 如 css、images 怎么配置呢?我也打算发布在他们那里
    -- by jimichan
  • NIO
    好,明白为什么存在了,谢谢
    -- by chyy001