How to create <input type=“text”/> dynamically

后端 未结 12 1067
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 10:47

I want to create an input type text in my web form dynamically. More specifically, I have a textfield where the user enters the number of desired text fields; I want the tex

12条回答
  •  醉酒成梦
    2020-12-02 11:27

    • Query and get the container DOM element

    • Create new element

    • Put new element to document Tree

    //Query some Dib region you Created
    let container=document.querySelector("#CalculationInfo .row .t-Form-itemWrapper");
    let input = document.createElement("input");
    
    //create new Element  for apex
    input.setAttribute("type","text");
    input.setAttribute("size","30");
    containter.appendChild(input); // put it into the DOM
    

提交回复
热议问题