如何从输入数组中获取输入元素的索引号 [英] How do I get the index number of an input element from Input Array
本文介绍了如何从输入数组中获取输入元素的索引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我在屏幕上的示例输出:
Here is my sample output on screen:
<form action="/Home/UpdateBooks" id="formBooks" method="post"><div class="isbns" style="margin:25px;">
<p><input class="text-box single-line" name="[0].isbn" type="text" value="hlkjh" /></p>
<p><input class="text-box single-line" name="[1].isbn" type="text" value="KhlkjhLK" /></p>
<p><input class="text-box single-line" name="[2].isbn" type="text" value="jhlkjhL" /></p>
<p><input class="text-box single-line" name="[3].isbn" type="text" value="saejhjkh" /></p>
<p><input class="text-box single-line" name="[4].isbn" type="text" value="1234567890" /></p>
<p><input class="text-box single-line" name="[5].isbn" type="text" value="1234567890" /></p>
</div>
我需要在a上添加一个输入元素按钮单击 - 添加更多。如何获取isbn输入数组的最后一个索引,以便我可以递增并附加到div?
感谢您提前帮助。我真的很感激!
I need to add an input element on a button click -"Add more". How do I get the last index of isbn input array so that i can increment and append to the div?
Thanks for helping in advance. I really appreciate it!
推荐答案
使用Jquery ....
试试这个,
Hi,
Using Jquery....
Try this,
var len =
(' 。text-box'跨度>)长度;
('.text-box').length;
这篇关于如何从输入数组中获取输入元素的索引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文