2021年1月18日星期一

Javascript: force input text inside div to be insidetags

I have <div> element with contenteditable="true" attribute, so I need to write each paragraph that the user will insert inside separate <p> element.

I have this div

<div class="internal-edit" contenteditable="true" placeholder="Add Question"></div>  

current inputs wrote like

<div class="internal-edit" contenteditable="true" placeholder="Add Question">  Lorem Ipsum  <div>Lorem Ipsum</div>  </div>  

and I need to add <p> element on input so the final element should be

<div class="internal-edit" contenteditable="true" placeholder="Add Question">  <p>Lorem Ipsum</p>  <p>Lorem Ipsum</p>  </div>  

so how can I achieve that?

https://stackoverflow.com/questions/65784064/javascript-force-input-text-inside-div-to-be-inside-p-tags January 19, 2021 at 08:49AM

没有评论:

发表评论