我试图在单击按钮时 append 输入标签并且成功了。我引用了很多链接
append new rows and input tags using jQuery
Jquery appended input button doesn't function with .on(click)
但现在的问题是我在表单中使用这些输入标签,并试图使用表单操作将这些输入标签值发送到下一页。但我无法发送 append 的输入元素值。
**
jquery
$("#addshowtime").click(function(){
$("<input type='time' value='' />")
.attr("id", "showtime5")
.attr("name", "show_timing5")
.prependTo("#showtime");
});
**
html
<label><strong>Show Timing1</strong></label><input id="showtime1" type="time" name="show_timing1" required/>
<label><strong>Show Timing2</strong></label><input id="showtime2" type="time" name="show_timing2" required/>
<label><strong>Show Timing3</strong></label><input id="showtime3" type="time" name="show_timing3" required/>
<label><strong>Show Timing4</strong></label><input id="showtime4" type="time" name="show_timing4" required/>
<cfinput type="button" id="addshowtime" class="btn" onClick="addInput()" name="add" value="+" />
<cfinput type="button" class="btn1" onClick="subInput()" name="sub" value="RESET" />
<p id="showtime">
</p>
最佳答案
我可以从您的代码中看出您必须 append 具有相同 ID 的输入标签。如果您通过 ID 检测输入标签来捕获值,则会导致问题。
关于jquery - 在 click jquery 上 append 输入标签并将这些值发送到操作页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18735735/