Soldiergirl50
asked on
HTM code
Hi I am tying to write code to translate to english on mousedown and french on mouseup. Can anyone assist. <p><span class="pnum">9</span><span class="phrase" onmousedown="swapFE()"
onmouseup="swapEF"></span> </p>
<p><span class="pnum">10</span><spa n class="phrase" onmousedown="swapFE()"
onmouseup="swapEF"></span> </p>
I have also included my script for .js file used.
function setUpTranslation() {
var phrases = document.getElementsByTagN ame("p");
for (var i=0; i<phrases.length; i++){
phrases[i].childNodes[1].i nnerHTML=f rench[i];
}
}
function swapFE(e) {
var phrase =eventSource(e);
var phrasenum= parseInt(phrases.previousS ibling().i nnerHTML);
phrase.innerHTML=english[p hrasenum-1 ];
phrase.style.fontStyle ="normal";
phrase.style.color = "rgb(155, 102, 102)";
}
function swapEF(e) {
phrase =eventSource(e);
phrase.innerHTML=french[ph rasenum-1] ;
phrase.style.fontStyle="it alic";
phrase.style.fontcolor=bla ck;
}
onmouseup="swapEF"></span>
<p><span class="pnum">10</span><spa
onmouseup="swapEF"></span>
I have also included my script for .js file used.
function setUpTranslation() {
var phrases = document.getElementsByTagN
for (var i=0; i<phrases.length; i++){
phrases[i].childNodes[1].i
}
}
function swapFE(e) {
var phrase =eventSource(e);
var phrasenum= parseInt(phrases.previousS
phrase.innerHTML=english[p
phrase.style.fontStyle ="normal";
phrase.style.color = "rgb(155, 102, 102)";
}
function swapEF(e) {
phrase =eventSource(e);
phrase.innerHTML=french[ph
phrase.style.fontStyle="it
phrase.style.fontcolor=bla
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
var phrases = document.getElementsByTagN
for (var i = 0; i < phrases.length; i++){
phrases[i].number = i;
phrases[i].childNodes[1].i
phrases[i].onmousedown = function (swapEF) {
this.childNodes[1].innerHT
this.childNodes[1]. style.fontStyle = "normal";
this.childNodes[1].style.c
}
phrases[i].onmouseup = function(swapFE) {
this.childNodes[1].innerHT
this.childNodes[1].style.f
thischildNodes[1].style.co
}
}
}
function swapFE(e) {
var phrase =eventSource(e);
if (IE) phrase.attachEvent("on" + mousedown, swapFE);
else if (DOM) phrase.addEventListener(on
var phrasenum= parseInt(phrases.previousS
phrase.innerHTML.nodeValue
phrase.style.fontStyle ="normal";
phrase.style.color = "rgb(0, 0, 0)";
}
function swapEF(e) {
var phrase =eventSource(e);
if (IE) phrase.attachEvent("on" + mouseup, swapFE);
else if (DOM) phrase.addEventListener(on
var phrasenum = parseInt (phrase.innerHTML.previous
phrase.innerHTML.nodeValue
phrase.style.fontStyle="it
phrase.style.fontcolor="rg
}