我对 Javascript 很陌生。我有一个错误:
未捕获的类型错误:无法读取 null fiddle.jshell.net:1163 的属性“孩子”(匿名函数)
如何修复错误?
在下面提供我的小提琴:
http://jsfiddle.net/N3GTy/29/embedded/result/
var slider = new Swipe(document.getElementById('slider'), {
callback: function(e, pos) {
var i = bullets.length;
while (i--) {
bullets[i].className = ' ';
}
bullets[pos].className = 'on';
}
}),
bullets = document.getElementById('position').getElementsByTagName('em'),
// tabs
tabs = new Swipe(document.getElementById('tabs'), {
callback: function(event, index, elem) {
setTab(selectors[index]);
}
}),
selectors = document.getElementById('tabSelector').children;
Uncaught TypeError: Cannot read property 'children' of null
for (var i = 0; i < selectors.length; i++) {
var elem = selectors[i];
elem.setAttribute('data-tab', i);
elem.onclick = function(e) {
e.preventDefault();
setTab(this);
tabs.slide(parseInt(this.getAttribute('data-tab'), 10), 300);
}
}