如何获取表单内所有输入的ID? [英] How to Get id's of all inputs inside the form?
本文介绍了如何获取表单内所有输入的ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取数组中表单内所有输入元素的ID?
How to get all id's of input elements inside a form in an array?
推荐答案
某些事情...
<script src="../../Scripts/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function ()
{
// Get all the inputs into an array...
var $inputs = $('#myForm :input');
// An array of just the ids...
var ids = {};
$inputs.each(function (index)
{
// For debugging purposes...
alert(index + ': ' + $(this).attr('id'));
ids[$(this).attr('name')] = $(this).attr('id');
});
});
</script>
这篇关于如何获取表单内所有输入的ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文