隐藏多个具有相同名称或类的标签 [英] Hiding multiple tag with same name or class

查看:84
本文介绍了隐藏多个具有相同名称或类的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是原型 1.5.你能告诉我,我如何隐藏/显示具有相同名称或类的 div 标签.

I have using prototype 1.5. Can you please tell me, how can i hide/show the div tag with same name or class.

Element.hide('indicate')

但是,上面这行只满足隐藏第一个元素.指示"是ID.

But, the above line only satisfy to hide the first element only. "indicate" is the id.

推荐答案

正如所指出的,$$ 函数是必需的.它返回一个数组,因此您需要invoke隐藏所有项目.>

As pointed out, the $$ function is required. It returns an array so you need to invoke hide on all items.

$$('.indicate').invoke('hide');

或者,为了获得额外的炫耀点数,您可以直接将该函数用作对象:

Or, for bonus showing off points, you can use the function directly as an object:

var hideFunc = Element.hide;
$$('.indicate').each(hideFunc);

这种技术的优势意味着您可以轻松地将功能替换为另一个功能,例如 一个 Scriptaculous效果.

The advantage of this technique means you can easily swap the function for another, such as a Scriptaculous effect.

hideFunc = Effect.SwitchOff;

这篇关于隐藏多个具有相同名称或类的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆