jquery - When clicking a button all texts are showing on the same div, i want it differentely -


i have page, when doing small task study, not working. problem is,

i have created input box , button, div showing texts typed on input box. when typed texts , clicked on button, working.

it means text showing in small div. when typed text , pressed button, div restarting. want duplicate div , should below of first. have listed jsfiddle below.

jquery code is

$(window).ready(function () {     $(".result-box").hide();  });  $("#button4").click(function () {      $(".result-box").show();      $(".result-box").animate({         top: '12%',         left: '8%'     });      var vof = $("#box1").val();     $(".result-box").text(vof);      $("#button4").val("next"); }); 

js fiddle

you can way:

$(window).ready(function(){  $(".result-container").hide();  });  $("#button4").click(function(){  var vof=$("#box1").val();  var newdiv ='<div class="result-box">'+vof+'</div>';  $(".result-container").append(newdiv);  $(".result-container").show();  $("#button4").val("next");  });
.small-box{  position:relative;  left:30%;  top:30%;  width:400px;  height:400px;  padding:30px;  border:5px solid #404040;  background:#f2f2f2;    }  .result-box{  position:relative;  left:9%;  top:10%;  border:3px solid #404040;  padding:10px;    font-family:verdana;  color:#fff;  width:80%;  background:#4d4d4d;      }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>    <div class="small-box">  <input type="text" id="box1" placeholder="enter value ?" />  <input type="button" name="button"  value="click me !"id="button4" />     <div class="result-container">  </div>  </div>


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -