JSFiddle - React, Tailwind, and code Playground

by yoowordpress

HTML

<div id="myfor">
		<p>	
            <label>Param 1 key 'test' </label><br />			
            <input type='text' name='test' value='<?php echo esc_attr( $test ); ?>'  size='60' />
            <span>Delete</span>
		</p> 
</div>
	
	<input type="button" value="Добавить" id="addnew">

JavaScript

// add live metod 
  jQuery.fn.live = function (types, data, fn) {
    jQuery(this.context).on(types,this.selector,data,fn);
    return this;
};

// add new input
  (function($){ 
	  $(function(){ 
	
		var num = 2;

        
		$('#addnew').click(function(){
			$('#myfor').append('<p><label>Param  '+ num +' key "test" </label><br ><input type="text" name="test" value=""  size="60" /> <span>Delete</span></p>');
			num ++;
		});
        
		
		$('span').live( 'click' , function(){  
		$(this).parent('p').children('input').val('').attr("type","hidden");      
        $(this).parent('p').children('label,br').remove();
        $(this).unwrap();
        $(this).remove();
        //$(this).parent('p').attr(type, hiden);
		});     
		
	});  
})(jQuery)