Amb*_*ber 15
$ids = $('#myform input[id]').map(function() {
return this.id;
}).get();
Run Code Online (Sandbox Code Playgroud)
Len*_*rri 14
有点像......
<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>
Run Code Online (Sandbox Code Playgroud)
您可以使用更精确的选择器缩小搜索范围:表单输入和具有 id 的属性选择器
$(document).ready(function() {
$('form input[id]').each(function() {
formId.push(J(this).attr('id'));
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19048 次 |
| 最近记录: |