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];

```
You basically put a condition and say name="some\_name".  

See the code below and observe that is still does insert the aragraph.

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

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

<script>
  YUI().use('node', function(Y) {
    var contentNode = Y.Node.create('<p>');
    contentNode.setHTML('Paragraph created by YUI by searching for *INPUNAME*...');
    Y.one('input[name="inpuname"]').insert(contentNode, 'after');
  });
</script>
```