2

Имеется модальное окно. Логика работы, при нажатие на кнопку добовляется два инпута. Делается через js? Есть пример?

0

2 ответа 2

3

function addTwoInputs() {
  var inp = document.createElement("input");
  inp.setAttribute("placeholder", "first");
  document.getElementById("container").appendChild(inp);

  inp = document.createElement("input");
  inp.setAttribute("placeholder", "second");
  document.getElementById("container").appendChild(inp);
}
<button onclick="addTwoInputs()">Click</button>
<div id="container"></div>

2

$("button").click(function() {
	$("div").append("<input type='text' placeholder='first'>");
	$("div").append("<input type='text' placeholder='second'>");
})
<div>
	<button>Click!!</button>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

2
  • А как задать id,как я узнаю какой будет, мне изьять данные нудно? 10 июл 2018 в 9:15
  • АйДи задается так id="id_name" 10 июл 2018 в 19:33

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.