Create input as child of input

后端 未结 5 1202
猫巷女王i
猫巷女王i 2021-01-19 15:07

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


    

相关标签:
5条回答
  • 2021-01-19 15:32

    Inputs can't have children because they do not end. Here's some info: https://www.w3schools.com/tags/tag_input.asp

    0 讨论(0)
  • 2021-01-19 15:38

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

    0 讨论(0)
  • 2021-01-19 15:45

    This would not be a valid approach to nest HTML elements in that way. If you take a look at what jQuery plugins do, they usually wrap your <select> element with divs and other stuff. IMHO, you can solve the problem by following a similar approach.

    0 讨论(0)
  • 2021-01-19 15:52

    This will result in invalid HTML, so its not possible to do this. What you can do is create a div, which is a block element and fill it with a text box + button Inline elements.

    With some styling in your CSS you can make your div look like a textbox and your textbox like a div, without borders and bevels. Resulting in something that looks like the thing you are trying to achieve here.

    To get rid of the textbox look on your input use #YourTextBox {border: none;}

    0 讨论(0)
  • 2021-01-19 15:53

    The correct answer is that the input tag is a void element that cannot have any children. Inline elements such as span can have children.

    Void elements only have a start tag; end tags must not be specified for void elements.

    i.e. in HTML5 there can never be a closing tag for an i.e. don't use </input>. HTML5 is not XML and it strongly discourages self-closing tags (/>) i.e. <input /> is not strictly correct HTML5 (although it will work for compatibility purposes). The list of void element tags defined in HTML5 are: area, base, br, col, embed, hr, img, input, keygen, link, meta, param, source, track, wbr.

    0 讨论(0)
提交回复
热议问题