line breaks in form element input value

前端 未结 2 983
夕颜
夕颜 2020-12-11 16:12

I am trying to add line breaks (aka newlines) to values of the input-element. , ,

相关标签:
2条回答
  • 2020-12-11 16:49

    The HTML input elements, type text or something similar (such as email) will deliberately strip off all line breaks, so that’s not going to work.

    The only form element which will accept line breaks is the textarea.

    Incidentally, Clipboard.js works by creating a dummy textarea element to do its magic.

    0 讨论(0)
  • 2020-12-11 16:58

    I don't actually think you can have line breaks for those types of form elements. You may have to use a <textarea> tag which allows for literal line breaks:

    <textarea id="multiliner" name="multiliner">line1
    line2
    line3</textarea>

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