如何像在 jQuery 中一样在 YUI 中显示/隐藏元素?
在 jQuery 中,当我想显示或隐藏某些内容时,我会这样做:
$('#elementId').show();
$('#elementId').hide();
How do I do this with YUI?我尝试过 YAHOO.util.Dom.get('elementId').hide(),询问我的同事,查看文档,并搜索 Google,但我发现没有任何帮助。从文档来看,这看起来应该可行
YAHOO.util.Dom.get('elementId').setStyle('display', 'none')
,但当然不行。我能想到的就是这个,这很糟糕,因为我没有使用框架:
document.getElementById('elementId').style.display = 'none';
In jQuery, when I want to show or hide something, I do this:
$('#elementId').show();
$('#elementId').hide();
How do I do this with YUI? I've tried YAHOO.util.Dom.get('elementId').hide(), asked my co-workers, looked at the documentation, and searched Google, and I've found nothing helpful. From the documentation, it looks like this should work
YAHOO.util.Dom.get('elementId').setStyle('display', 'none')
but of course it does not. All I can think of is this, which sucks because then I'm not using a framework:
document.getElementById('elementId').style.display = 'none';
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以省略 Dom.get。
仅供参考,在 YUI 3 中(截至 3.3.0pr3)
对于 YUI 3.2-
You can omit the Dom.get.
FYI, in YUI 3 (as of 3.3.0pr3)
For YUI 3.2-
显然我必须这样做:
可笑且不必要的长,但它似乎有效。
Apparently I have to do this:
Ridiculously and unnecessarily long, but it seems to work.