Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create input as child of input

Tags:

html

jquery

dom

Is it possible to create a button that is the child of an text?

<input type="text">
    <input type="button" />
</input>

The reason I ask is I would like to make a combo box. See this fiddle. Doing this in jquery, the button does not appear. Doing it in regular html, the 2nd input is not a child of the first (in Chrome at least).

I could put a text and button in a span, but I prefer to create the text box like in the example so later the value can be retrieved like: $("#test).val();

PS I know other combo box plugins exist. I would like to roll my own for learning purposes.

like image 805
Johnny Mopp Avatar asked Dec 12 '22 20:12

Johnny Mopp


1 Answers

This is not possible as input is an inline element - it cannot have children.

like image 112
Rory McCrossan Avatar answered Dec 27 '22 23:12

Rory McCrossan