gpt4 book ai didi

dom - 在 Prototype 中使用 $$ 是不是不好?

转载 作者:行者123 更新时间:2023-12-02 17:58:41 25 4
gpt4 key购买 nike

原型(prototype) JS API documentation提到了 $$() 函数,它允许您基于 CSS 选择器选择和扩展元素,就像 jQuery 中的 $() 函数一样。

但是,在该页面上,$$ 显示为某种最后的手段:

Sometimes the usual tools from your DOM arsenal just aren't enough to quickly find elements or collections of elements. If you know the DOM tree structure, you can simply resort to CSS selectors to get the job done.

这是为什么呢?我应该远离 $$ 而只使用 document.getElementsByClassName (呃)吗?

最佳答案

根据您写的那句话,我想说他们鼓励您使用$$()$$() 为您提供了一种跨浏览器的方式来快速轻松地访问元素。另一方面,document.getElementsByClassName()buggy or not functional in IE version up to and including version 8 .

关于dom - 在 Prototype 中使用 $$ 是不是不好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6441506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com