- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我刚从 YUI2 切换到 YUI3。因此,我没有使用 YAHOO.util.Dom.get(ID_OF_ELEMENT)
,而是尝试使用 Y.one('#ID_OF_ELEMENT)'
。它适用于 id img123 的 div,但不适用于 123img 或 123>.
我也尝试过使用 Y.all
但它没有用。我发现让它工作的唯一方法是使用 Y.DOM.byId
(显示为 alternative in YUI forum ),同时仍然使用 YUI。
所以我所做的是用最后一个获取元素并用第一个获取节点,如下所示:
Y.one(Y.DOM.byId(ID_OF_ELEMENT)).append(SOME_HTML_CONTENT);
我不能单独使用 Y.DOM.byId
,因为我需要将它的内容作为一个 Node 进行操作。
那么,有没有办法只使用 Y.one
来做到这一点? 这是 YUI 错误吗?
我已经对此发表了评论 YUI forum entry ,因为我不知道这是否真的是我可以填写的错误 YUI bug reporting tool .
最佳答案
如果你使用 html4:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
另见 this link .
===更新===
对于 html5:
在您使用 Y.one(...)
的示例中,yui 调用浏览器的 native 查询选择器:querySelector(selector)
(请参阅 here)。
但并非所有浏览器的 querySelector 函数都接受所有允许的 html5 id
。例如。 firfox10 native 查询选择器对于具有起始数字的 id
失败(在不同的浏览器中尝试 this example)。
为什么? Mozilla 使用 CSS2.1 规范选择器:
火狐 links in his querySelector documentation到选择器 API 级别 1。
在first chapter "Abstract" :
Selectors, which are widely used in CSS, are patterns that match against elements in a tree structure [SELECT][CSS21].
[SELECT]链接到 Selectors Level 3在 chapter 6.5 "ID selectors" 中:
...
An ID selector contains a "number sign" (U+0023, #) immediately followed by the ID value, which must be an CSS identifiers.
...
来自链接css2.1 identifiers specification :
In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier "B&W?" may be written as "B\&W\?" or "B\26 W\3F".
===更新===
您可以使用以下选择器 [id="123"]
。例如:
YUI().use('node', function (Y) {
Y.one('[id="123"]').on("click", function (e) {
alert("Hello World!");
});
});
另见 this example .
关于javascript - YUI 通过 id 方法获取元素不适用于数字起始 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9134628/
在过去的两年里,我一直在广泛使用 jQuery 和 ExtJs 进行编程。我认为现在是时候花一些时间来学习令人印象深刻的 YUI 库了。 在从头开始学习方面什么是可取的? 我不打算在我 future
我们使用 YUI3 加载器来管理加载我们的 javascript 和 css 文件。作为每个页面上引导 js 代码的一部分,我们有如下内容: YUI({ ... groups: {
我有一个 YUI 数据表,我将以下数据放入表中: {key:"name", label:"name", editor: nameChoiceEditor}, {key:"group", label
我想向已经包含 Prototype 和 Scriptaculous 的页面添加日历控件。对我能找到的任何原型(prototype)都不满意,我正在考虑使用 YUI 日历小部件。 我这可能会导致什么问题
我可以使用多个下拉菜单和分页的 YUI 数据表来过滤静态数据集的行吗? http://www.mappingbahia.org/project/iguape_dataset.html 最佳答案 每个
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 9 年前。 Improv
在我们的 SSL 页面上使用 YUI 脚本会破坏 SSL 连接,因为它们通过 http 连接动态加载来自 yahoo(组合)的脚本。 由于我们只使用 YUI 3 的历史管理器,所以我想将代码托管在我们
我使用以下代码通过 YUI 在页面正文中创建一个 html 元素。此代码不会产生任何错误。 问题是,段落元素没有在 html 页面中创建。 YUI Test
YUI Compressor,在其(不是很广泛的)文档中将其作为一个选项: --disable-optimizations Disable all the built-in micro opt
如果我运行这样的测试用例,我的测试结果将显示在 YUI 测试控制台小部件中: YUI({debug: true}).use('test', 'event-base', 'test-console',
YUI.add 和 YUI().add 有什么区别? 最佳答案 在第一种情况下,您要注册一个模块可以加载到 YUI 沙箱中,在第二种情况下,您要构建一个沙箱,然后进行注册(这是一种非常不典型的用法)。
我一直在使用 YUI 库来开发网站。 YUI 3 于 9 月发布。 我仍然不确定是否必须为迁移做好准备。 第三版比第二版有什么优势? 您最近参与过这样的迁移吗? 最佳答案 我没有参与迁移,但我为 YU
将 Yahoo JS 和 CSS 库从版本 2 升级到版本 3 的迁移路径是什么? 特别是:CSS 和字体、按钮、TabView。 如能提供有关所遇到问题的更多信息、简化问题的提示等,我们将不胜感激。
我遇到的问题是它也跟踪日志阅读器中的所有事件。这使得它很难使用。当我向上向下滚动、在阅读器中单击或移动以检查事件时,它会在各处滚动以添加新事件。有没有办法过滤它以仅包含来自某些来源的某些事件?我可能做
这个问题主要是出于学术兴趣。 我今天开始使用 YUI 3,并偶然发现了它的沙箱概念。在彻底尝试在 DOM 中找到一些对象(比如我注册的事件处理程序)后,我不得不放弃。我只是找不到任何实例对象结束于此。
YUI 似乎非常专注于为浏览器和 node.js 提供所有相同的代码。 这非常强大,因为现在我可以在两端使用相同的测试,而不必重写/重新学习任何东西。 在测试方面,谷歌是否也专注于 node.js?
我正在尝试使用 Maven 的 YUI Compressor 插件来压缩我的 CSS 和 JavaScript,但我遇到了两个问题。 我的配置正确地压缩和聚合了 JavaScript 文件,但是如果我
我正在使用Yahoo.Yui.Compressor.Build.MsBuild压缩 css 和 javascript 文件。我已经安装了Yahoo.Yui.Compressor.Build.MsBui
我正在尝试使用 YUI 3.3.0 预览版 3 charting solution因为它不再使用 Flash,而是使用浏览器 Canvas 。到目前为止,我把这些和平的代码拼凑在一起(因为我是 YUI
我正在使用 YUI,需要获取元素的真实宽度。元素的宽度可以如下确定。 宽度 + 左边框 + 右边框 + 左填充 + 右填充 + 左边距 + 右边距。 下面是我想出的。它似乎正在工作。我只是想知道这是确
我是一名优秀的程序员,十分优秀!