现在,如果我想隐藏我执行的所有 account
block
Element.hide('account_1_info')
Element.hide('account_1_friends')
Element.hide('account_1_contacts')
Element.hide('account_2_info')
Element.hide('account_2_friends')
Element.hide('account_2_contacts')
etc...
是否可以通过 ID 掩码 account_*
(或通过正则表达式)隐藏所有 block ?
最佳答案
在 prototypejs 和 CSS 选择器中使用双美元:
$$('*[id^="account_"]')
从 1.7 版开始,prototypejs 使用 sizzle,它与 jquery 使用相同的 selector-enginge,因此您可以使用 jquery-documentation 来了解选择器。 http://api.jquery.com/category/selectors/
关于javascript - 通过 id 隐藏 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6041573/