Create Button again and again OnClick

Posted by Tabrez under jQuery category on | Points: 40 | Views : 1658
<!DOCTYPE html>
<html xmlns="">
<script src=""></script>
<title>Create Button Again and Again</title>
border:3px solid red;

<div id="KeepContent" class="parallel">
<button onclick="dynamichtml();">Create Button</button>

<script type="text/javascript">
var count = 0;
function dynamichtml() {
var d = $("#KeepContent");

var btn = document.createElement("input");
btn.type = "button"; = "btn_"+count;
btn.value = "New Button";

d.delegate('#btn_'+count, "click", function () {



Comments or Responses

Posted by: Amatya on: 2/16/2016 Level:Silver | Status: [Member] | Points: 10
What is the use of this code.. where we can use.. Have you used in application?
Posted by: Tabrez on: 2/16/2016 Level:Starter | Status: [Member] | Points: 10
In most of the situations we create some dynamic controls when user want to give extra information about her/himself like A Button for Add Extra Curricular, Add More Work Experience in that situation we create some dynamic elements for add that and bind the Submit button with an event to store the data.
It is just for understanding how to register delegate on previous button or new button that's it.

Login to post response