You are attempting to call the select
Javascript method.
For an Input or TextArea element, this will focus the element and select all the text in it.
However you haven't got an input
or a textarea
element. You've actually got a text node. You were trying to find the first child element of the div, but there was a text node before it, and text nodes are selected when you do childNodes
.
The easy way round this is to use jQuery to do the whole selection instead:
$("#grid_modal div").eq(0).children().first()[0].select()
You can do it with vanilla Javascript instead. For instance, you can use the children
property, but this isn't available across all browsers (in particular in IE<9).
$("#grid_modal div")[0].children[0].select()