2012-03-07 41 views
0

点击“添加另一个开始和结束时间”。请注意,“删除此段”。按钮的行为就好像它们的类型未被更改一样。我通过JSLint运行这个没有任何问题,我没有在控制台中得到错误。在Chrome中使用Web开发人员工具,看起来它的类型属性没有设置。我无法弄清楚发生了什么事。为什么即使将按钮的类型设置为按钮(而不是提交),按钮也会提交表单?

http://jsfiddle.net/gtr053/xtGPR/

回答

2

火狐说:

Error: uncaught exception: [Exception... "Index or size is negative or greater than the allowed amount" code: "1" nsresult: "0x80530001 (NS_ERROR_DOM_INDEX_SIZE_ERR)" location: "http://fiddle.jshell.net/gtr053/xtGPR/show/ Line: 39"]

第39行是:

document.getElementById('start_end_times').getElementsByTagName('tbody')[0].deleteRow(index); 

所以想必指数是错误的。

+0

啊。更改'removeButton.onclick = function(){removeStartEndTime(removeButton.parentNode.parentNode.rowIndex); };'remove'removeButton.onclick = function(){removeStartEndTime(this.parentNode.parentNode.rowIndex - 1); };'谢谢。 – 2012-03-07 03:14:27

+0

我没有得到任何错误,直到我把它扔到jsFiddle出于某种原因。 :/ – 2012-03-07 03:15:44