这对 JavaScript 来说是非常基本的,但我很难过,所以任何帮助都将不胜感激。
我想使用对象的第二个子节点中发生的 mouseDown 事件在 for 循环中调用一个函数。斜体部分是我的尝试。顺便说一句,swapFE 功能仍在进行中。还有一件事是,当我将斜体部分放在 swapFE 函数中时,一切正常,但是当我将它放在 for 循环中时,它并没有全部显示出来。我不知道为什么。当我用鼠标单击短语时,我基本上是在尝试将法语短语换成英语短语。
function setUpTranslation() {
var phrases = document.getElementsByTagName("p");
var swapFE = document.getElementsByTagName("phrase");
for (i = 0; i<phrases.length; i++) {
phrases[i].number = i;
phrases[i].childNodes[1].innerHTML = french[i];
*phrases[i].childNodes[1].onMouseDown = swapFE;*
}
}
/* see "function_swapFE(phrase,phrasenum);" below. The expression to call function swapFE
is located underneath "function swapFE(e)" because although the directions said to put the
"run swapFE" within the for loop it did not work properly that's why I put it beneath the
"function swapFE(e)".*/
function swapFE(e) {
var phrase = eventSource(e);
var phasenum = parseInt(1) = [1].innercontent.previousSibling;
phrase.node.previousSibling.onmousedown=swapFE
function_swapFE(e)(phrase,phrasenum);
}
}
如果您有任何问题,请告诉我。
谢谢你的帮助。