Clicking



  • There is a form of comment, after completing the form of the comment and putting the button on it, the text must be presented in the block.

    About this (the whole code below should only appear after the button is pressed):

    <div class="result">
      <div class="name">
          Здесь название
      </div>
      <div class="comment">
         Здесь какой-то текст
           для примера
      </div>
    </div>
    

    Now I've prepared a form, I'd only have a violin that will extract the text from the shape and put it in the block.

    https://jsfiddle.net/engenes/Lzqr56ed/6/

    (sighs) Yeah, I know that once the page and the block are updated, the text is missing. But that's not the point. I'm just saying that this bloc with the text above appears.



  • That's the basis of the method. I think it's easy to apply to your task:

    function onClick() {
        var container = document.getElementById("container");
        var textarea1 = document.getElementById("textarea1");
        var text1 = document.getElementById("text1");
    
    var div1 = document.createElement("div");
    div1.className = "div1";
    div1.innerHTML = text1.value;
    
    var div2 = document.createElement("div");
    div2.className = "div2";
    div2.innerHTML = textarea1.value;
    
    var div = document.createElement("div");
    div.className = "divA";
    div.appendChild(div1);
    div.appendChild(div2);
    
    container.appendChild(div);
    

    }

    .divA {
    border: 1px solid gray;
    }
    .div1 {
    background-color: #fdd;
    }
    .div2 {
    background-color: #ddf;
    }
    <div id="container"></div>

    <input type="text" id="text1" />
    <br />
    <textarea id="textarea1" cols="40" rows="3"></textarea>
    <br />
    <button onclick="onClick();">Send</button>




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2