YUI Dom.getChildren
当你的类是动态的并且只有父类有 id 时,你可以更改没有 id 的类吗?
我有这样的想法:
<div id="number_block">
<div class="one science easy left"></div>
<div class="one science easy center"></div>
<div class="one science easy right"></div>
</div>
我只到达这部分
var number_block_children = Dom.getChildren('number_block');
for(var i=0; i < number_block_children.length; i++)
{
/* I don't know the syntax to change class name here for every child, is it possible?
* I can't use Dom.getElementByClassName...since the class is dynamic.
* It's something similar to how get classname by id, only I don't have id, just parent id:
* Dom.get('id-name-here').className
* I can't figure out how to do this....
*/
}
谢谢!
Can you change classes without id when your classes are dynamic and only the parent has an id?
I have something like:
<div id="number_block">
<div class="one science easy left"></div>
<div class="one science easy center"></div>
<div class="one science easy right"></div>
</div>
I only reach this part
var number_block_children = Dom.getChildren('number_block');
for(var i=0; i < number_block_children.length; i++)
{
/* I don't know the syntax to change class name here for every child, is it possible?
* I can't use Dom.getElementByClassName...since the class is dynamic.
* It's something similar to how get classname by id, only I don't have id, just parent id:
* Dom.get('id-name-here').className
* I can't figure out how to do this....
*/
}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 getAttribute 来获取元素类:
You can use getAttribute to get element classes:
嘿你可以做一些事情
希望它有帮助
hey you can do something like
hope it helps