Try this:
$("div.data_form input").on("keyup", function(e){ $(e.target).closest(".data_form").find(".newprog").text($(this).val()); });
Words can be described as follows: in the event of an input element, we are looking for the first parent element with the data_form class and from it downwards we are looking for an element with the newprog class. More about event.target here .
Sample code .
If you add blocks using a script, then this example will not work. In this case, you need to "wrap" the blocks, for example in a div and have an event handler on it:
$("button").on("click", function() { $(".data_form:first").clone().appendTo(".container"); }); $("div.container").on("keyup", "input", function(e) { $(e.target).closest(".data_form").find(".newprog").text($(this).val()); e.preventDefault(); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button>Add new container</button> <div class="container"> <div class="data_form"> <div class="newprog">Текст инпута 1</div> <div> <input /> </div> </div> </div>
JSFiddle example