2
news_divs[i].innerHTML= content.substr(0,this.config.head_length)+"...<div style='display:none'>"+content+"</div>";
news_divs[i].onclick = function(){var child=this.getElementByTagName('div')[0];child.style="display:block;"}
但在最後一個字符串返回錯誤。 錯誤文本:
Uncaught TypeError: undefined is not a function news_div.js:9
news_divs.(anonymous function).onclick
我測試:
news_divs[i].onclick = function(){var child=this.firstChild;child.style="display:block;
和
news_divs[i].onclick = function(){var child=this.children[0];child.style="display:block;
但總是得到這個錯誤。
當我所著(實施例):
news_divs[i].onclick = function(){console.log('test')}
而工作。
news_div
不確定。
我想我有錯誤,因爲我的問題是不正確的。 這是正確的嗎?
其中「I」被設置的方式嗎? – attila