【发布时间】:2018-08-13 14:34:09
【问题描述】:
大家好,我需要知道如何在调用函数时将类索引传递给函数。
假设我有 3 个像这样的输入标签:
<input type="text" placeholder="email" class="PIC"
onchange="val(this.getAttribute('class'), **index0**)" />
<input type="text" placeholder="email" class="PIC"
onchange="val(this.getAttribute('class'), **index1**)" />
<input type="text" placeholder="email" class="PIC"
onchange="val(this.getAttribute('class'), **index2**)" />
现在我想做的就像我传入类名一样,我想传入调用函数的类索引。 index0 应该传入 0 index1 1 应该传入 1 等等...
假设函数 val 是这样的:
function val(className, Index) {
alert('class is ' + className + ' and the index is: ' + index);
}
【问题讨论】:
-
类索引是什么意思?
标签: javascript function class arguments