添加新输入类型后,如何关闭焦点?

时间:2015-10-21 12:55:51

标签: javascript jquery html css

添加新的inpu后,如何关闭焦点?我想这样做,因为当我在我的iPad上并按"添加字段"它会自动调出键盘。这非常烦人,因为有时我想在输入数据之前添加一些新的输入字段。



		$('.multi-field-wrapper').each(function() {
			var $wrapper = $('.multi-fields', this);
			$(".add-field", $(this)).click(function(e) {
				$('.multi-field:first-child', $wrapper).clone(true).appendTo($wrapper).find('input').val('').focus();
			});
			$('.multi-field .remove-field', $wrapper).click(function() {
				if ($('.multi-field', $wrapper).length > 1)
					$(this).parent('.multi-field').remove();
			});
		});
			

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="" method="POST" style="height:50px;">
 <input type="submit" name="stocksave" value="Save" class="float" style = "float:right;">  
 </br></br>
	 
   <div class="multi-field-wrapper focusoff">
   
	  <div class="multi-fields focusoff">
		 <div class="multi-field focusoff">
			<input type="text" name="stockitem[]" autocomplete="off" class="focusoff">
			<select name='piecesdd[]' style='width:150px; '>
			
			   <option value='0'>PIECES</option>
			   <?php
				  $count = 1;
				  while ($count<=100) {
					echo "<option value='".$count."'>".$count."</option>";
					$count++;
				  };
				  ?>
			</select>
			<button type="button" class="remove-field">Remove</button>
			
			<button type="button" class="add-field">Add field</button>
			
		 </div>
		  
	  </div>
     
	</div>
	
  
</form>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

.focus() - .add-field

的下一行删除click event
$('.multi-field:first-child', $wrapper).clone(true).appendTo($wrapper)
.find('input').val('').focus()

所以它只是

$('.multi-field:first-child', $wrapper).clone(true).appendTo($wrapper)
.find('input').val('')