Tuesday, June 30, 2015

Add Remove multiple textfield with jquery



<html>
<head>


<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js"></script>
<script>
            $(document).ready(function() {
                $(".add").click(function() {
                    $('<div>
<input class="textbox" name="m" value="dynamic text field"><span class="rem" ><a href="javascript:void(0);" >Remove</span></div>
').appendTo(".contents");
                });
            });
</script>


<script>
$('.contents').on('click', '.rem', function() {
  $(this).parent("div").remove();
});
</script>
</head>
<body>


<input class="textbox" name="n" value="static text field" /><span><a class="add" href="javascript:void(0);">Add More</a></span>
<div class="contents">
</div>
</body>

</html> Add More

No comments:

Post a Comment