Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

Newby needing HTML assitance

$
0
0

I use the flashcard program Anki to learn Spanish. I am trying to work on some code to look up the allow me to click on the individual words for a definition. I seem to be getting inconsistent results do to returns and formatting included in the text. Any help would be appreciated.

<script>

var content = document.getElementById("Esp Sentence").innerHTML;
var bldRepl = content.replace(/<b>/g,"");
var itlRepl = bldRepl.replace(/<i>/g,"");
var unlRepl = itlRepl.replace(/<u>/g,"");
var divRepl = unlRepl.replace(/<div>/g,""); 
var brRepl = divRepl.replace(/<br>/g,"");
var punctuationless = brRepl.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()\?\¿\¡]/g, "");
var mixedCase = punctuationless.replace(/\s{2,}/g, "");
var finalString = mixedCase.toLowerCase();
var words = (finalString).split("");
var punctuatedWords = (brRepl).split("");
var processed = "";

for (i = 0; i < words.length; i++) {
    processed += "<a href = \"https://www.spanishdict.com/translate/" + words[i] + "#Spanish\">";
    processed += punctuatedWords[i];
    processed += "</a> ";
}

document.getElementById("Esp Sentence").innerHTML = processed;
</script>

Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>