JQuery

[Dynamic textbox] How to create textbox in jQuery?

[Dynamic textbox] How to create textbox in jQuery? , someone asked me to explain?

In this article, I will show you how to create a textbox control dynamically in JQuery. You can add textbox using keyword attr and pass a parameter of textbox attribute fields such as text, name, id etc. and append to the div element. 

<script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
<script type="text/javascript">
        $(document).ready(function () {
            var $ctrl = $('<input/>').attr({ type: 'text', name: 'text', placeholder: 'text' }).addClass("text");
            $("#divcontent").append($ctrl);
        });
    </script>
<body style="border:1px solid #0094ff;padding:5px 10px 5px 10px;width:500px;height:350px">
    <div class="container">
        <div class="row">
            <h2> how to add text box dynamically using JQuery</h2>
<button id="btnGenerate" >Generate Text Control</button>
            <br />
            <i>click above button</i>
            <div id="divcontent"></div>
        </div>
    </div>
</body> 

Output:

How to create textbox in jQuery?

Post your comments / questions