sharan desai
sharan desai

Reputation: 11

document.getElementsByName("") equivalent in YUI3.0

AS we know that to get value of an element by ID in YUI3.0 we use below code.

Y.one("#element_id");

Is there any equivalent code in YUI 3.0 for document.getElementsByName("element_name"); of javascript.

Upvotes: 1

Views: 142

Answers (1)

Byran Zaugg
Byran Zaugg

Reputation: 957

You can use any CSS selector, such as the attribute selector.

var all_element_names = Y.all('[name="element_name"]');

Also, keep in mind, if the browser supports the native getElementsByName() method, YUI will use it. But if the browser does not support the native method, YUI will brute force the DOM to find the attribute, with a performance penalty.

Upvotes: 1

Related Questions