26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
|
function checkMultipleInput() {
|
||
|
$(".multipleInput").each(function() {
|
||
|
$(this).children('.controls').length==1 ? $(this).addClass("plural") : $(this).removeClass("plural")
|
||
|
});
|
||
|
}
|
||
|
function removeInput(){
|
||
|
$(".removeInput").click(function (){
|
||
|
$(this).parents(".controls").remove();
|
||
|
checkMultipleInput();
|
||
|
return false;
|
||
|
});
|
||
|
}
|
||
|
$(document).ready(function(){
|
||
|
var $modalNumber = 0;
|
||
|
checkMultipleInput();
|
||
|
removeInput();
|
||
|
$(".addinput").click(function (){
|
||
|
$modalNumber+=1;
|
||
|
var $CloneTarget = $(this).parents(".controls").prev(".multipleInput").children('.controls:last');
|
||
|
$(this).parents(".controls").prev(".multipleInput").append($CloneTarget.clone());
|
||
|
$(this).parents(".controls").prev(".multipleInput").children('.controls:last input').val("");
|
||
|
removeInput();
|
||
|
checkMultipleInput();
|
||
|
return false;
|
||
|
})
|
||
|
});
|