Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何创建更多次的重复输入?_Javascript - Fatal编程技术网

Javascript 如何创建更多次的重复输入?

Javascript 如何创建更多次的重复输入?,javascript,Javascript,我想让这个js在同一个页面中工作多次,它只在第一个块中工作 $(document).on('click', '.btn-add', function (e) { e.preventDefault(); var controlForm = $('.controls form:first'), currentEntry = $(this).parents('.entry:first'), newEntry = $(current

我想让这个js在同一个页面中工作多次,它只在第一个块中工作

    $(document).on('click', '.btn-add', function (e) {
      e.preventDefault();
      var controlForm = $('.controls form:first'),
          currentEntry = $(this).parents('.entry:first'),
          newEntry = $(currentEntry.clone()).appendTo(controlForm);
      newEntry.find('.repeat').val('');
      controlForm.find('.entry:not(:last) .btn-add')
          .removeClass('btn-add').addClass('btn-remove')
          .removeClass('btn-success').addClass('btn-danger')
          .html('<svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><circle cx="12" cy="12" r="10"></circle><line x1="8" y1="12" x2="16" y2="12"></line></svg>'); 
  }).on('click', '.btn-remove', function (e) {
      $(this).parents('.entry:first').remove();
      e.preventDefault();
      return false;
  });
$(文档).on('click','btn add',函数(e){
e、 预防默认值();
var controlForm=$('.controls-form:first'),
currentEntry=$(this).parents('.entry:first'),
newEntry=$(currentEntry.clone()).appendTo(controlForm);
newEntry.find('.repeat').val('');
controlForm.find('.entry:not(:last).btn add')
.removeClass('btn-add')。addClass('btn-remove'))
.removeClass('btn-success').addClass('btn-danger'))
.html(“”);
}).on('click','btn remove',函数(e){
$(this).parents('.entry:first').remove();
e、 预防默认值();
返回false;
});