I have to split a phrase. First im not sure exactly how to do that, do I use
var str="my phrase here"
str. split=(" ")
Is there a way to not put the entire phrase, or do I have to put
var str="It’s that time of year when you clean out your
closets, dust off shelves, and spruce up your floors. Once you’ve taken
care of the dust and dirt, what about some digital cleaning? Going
through all your files and computers may seem like a daunting task, but
we found ways to make the process fairly painless"
also I would like to Iterate over that array, at each step and build SPAN elements as I go, along with the attributes
The html I have is
<div id="transcriptText"> It’s that time of year when you clean out your
closets, dust off shelves, and spruce up your floors. Once you’ve taken
care of the dust and dirt, what about some digital cleaning? Going
through all your files and computers may seem like a daunting task, but
we found ways to make the process fairly painless<pre lang="Javascript"></div>
<br>
<div id="divideTranscript" class="button"> Transform the
Transcript! </div>T
I had
function splitString(stringToSplit, separator) {
var arrayOfStrings = stringToSplit.split(separator);
print('The original string is: "' + stringToSplit + '"');
print('The separator is: "' + separator + '"');
print("The array has " + arrayOfStrings.length + " elements: ");
for (var i=0; i < arrayOfStrings.length; i++)
print(arrayOfStrings[i] + " / ");
}
var space = " ";
var comma = ",";
splitString(tempestString, space);
splitString(tempestString);
splitString(monthString, comma);
for (var i=0; i < myArray.length; i++)
{
}
var yourSpan = document.createElement('span');
yourSpan.innerHTML = "Hello";
var yourDiv = document.getElementById('divId');
yourDiv.appendChild(yourSpan);
yourSpan.onmouseover = function () {
alert("On MouseOver");
}
I also need to add the span elements to the original div, and Add a click handler to the SPAN elements, or to the DIV, which causes the style on the SPAN to change on mouseover
I have been stuck on this for quite some time, and asked on a different website but no answer was enough to help me, I have substantial trouble with coding and stuff that seems simple just leaves me stuck, I could really use some help.