如何通过Jquery点击链接添加输入

How to add inputs by clicking link through Jquery?

本文关键字:链接 添加 输入 何通过 Jquery      更新时间:2023-09-26

我有4个输入,其中3个是隐藏的。我想要的是每当用户想要"添加更多图片"时。单击链接时,它将显示隐藏的输入。我不知道它将如何在Jquery中工作?如果有人帮忙,我会很感激的。

<html>
<head>
</head>
<body>
<form>
<input type="file" id="pic1" />
<input type="file" style="display:none;" id="pic2" />
<input type="file" style="display:none;" id="pic3" />
<input type="file" style="display:none;" id="pic4" />
<a href="#" id="AddMore">Add More Links</a>
</form>
</body>
</html>

试试这个:

$('#AddMore').click(function(e){
   e.preventDefault();
   $('input[type="file"]:hidden:first').show()
})

演示