YUI gets an element by id method, which does not work for numeric starting identifiers

I just switched from YUI2 to YUI3. So instead of using, YAHOO.util.Dom.get(ID_OF_ELEMENT)I tried to use Y.one('#ID_OF_ELEMENT)'. It works fine for div with id img123 , but not with 123img or 123 .

I also tried using Y.all, but that didn't work. The only way I worked when using YUI was to use Y.DOM.byId(shown as an alternative in the YUI forum ).

So, I did to grab the element with the latter and first get the Node, for example:

Y.one(Y.DOM.byId(ID_OF_ELEMENT)).append(SOME_HTML_CONTENT);

I could not use it only Y.DOM.byIdbecause I needed to manipulate content like Node.

So, is there a way to do this using only Y.one? Is this a YUI error?

I made a comment on this page of the YUI forum , since I do not know if this is really a mistake that I could fill in with the YUI Error Reporting Tool .

+5
source share
1 answer

If you are using html4:

IDs and NAMEs must begin with a letter ([A-Za-z]), followed by any number of letters, numbers ([0-9]), hyphen ("-"), underscore ("_"), colon (":") and periods (".").

Also see this link .

=== UPDATE ===

For html5:

Y.one(...) yui : querySelector(selector) (. ).
querySelector function html5 id s. . firfox10 id ( ).
? Mozilla CSS2.1 :
Mozilla querySelector API Selectors 1.
"" :

, CSS, , [SELECT] [CSS21].

[SELECT] 3 6.5 " " :

...
   " " (U + 0023, #), , CSS.
  ...

css2.1:

CSS ( , ) [a-zA-Z0-9] ISO 10646 U + 00A0 , (-) (_); , , . ISO 10646 (. ). , "B & W?" "B\& W \?" "B\26 W\3F".

=== UPDATE ===

[id="123"]. :.

YUI().use('node', function (Y) {
    Y.one('[id="123"]').on("click", function (e) {
        alert("Hello World!");
    });
});

. .

+8

All Articles