Question: How can I use YUI to locate a text input by name and insert a div after it?

For example, this doesn't work:

```
<input name="some_name" type="text">

<script>
var el = new YAHOO.util.Element(document.createElement('div'));
var some_element = document.getElementsByName('some_name');

// doesn't work .... replacing 'some_element' with 'document.body' works
el.appendTo(some_element);

</script>

```

Answer: 
document.getElementsByName('some\_name') always return a collection (an Array), if you are sure that the name is unique you can safely write this.

```
var some_element = document.getElementsByName('some_name')[0];

```
With YUI 3 you can now do [this](https://stackoverflow.com/a/21319966/274502):

```html
<script src="http://yui.yahooapis.com/3.18.1/build/yui/yui-min.js"></script>

<input id="some_id" type="text">

<script>
  YUI().use('node', function(Y) {
    var contentNode = Y.Node.create('<p>');
    contentNode.setHTML('This is a para created by YUI...');
    Y.one('#some_id').insert(contentNode, 'after');
  });
</script>
```

But keep in mind [YUI is being discontinued](http://yahooeng.tumblr.com/post/96098168666/important-announcement-regarding-yui)!