<div class="filterSection">
<input id="oInput" type="text" placeholder="请输入......">
<span sex="m">male</span>
<span sex="f">female</span>
<span class="active" sex="a">all</span>
</div>var oSpanArr = Array.prototype.slice.call(document.getElementsByTagName('span'),0);
var lastSpan = oSpanArr[2];
oSpanArr.forEach(function(ele,index){
ele.onclick = function () {
this.className = 'active';
lastSpan.className = '';
lastSpan = this;
var filterSex = this.getAttribute('sex');
renderPage(filterArrByText(personArr,filterSex));
}
});请问,oSpanArr是数组,他能调用onclick方法吗?
<input id="oInput" type="text" placeholder="请输入......">
<span sex="m">male</span>
<span sex="f">female</span>
<span class="active" sex="a">all</span>
</div>var oSpanArr = Array.prototype.slice.call(document.getElementsByTagName('span'),0);
var lastSpan = oSpanArr[2];
oSpanArr.forEach(function(ele,index){
ele.onclick = function () {
this.className = 'active';
lastSpan.className = '';
lastSpan = this;
var filterSex = this.getAttribute('sex');
renderPage(filterArrByText(personArr,filterSex));
}
});请问,oSpanArr是数组,他能调用onclick方法吗?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货