Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the code
C#
function splitString(stringToSplit, separator) {

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."
var myArray = stringToSplit.split(" ")



for (var i=0; i < myArray.length; i++)
{

}
var yourSpan = document.createElement('span');
yourSpan.innerHTML = "";

var yourDiv = document.getElementById('divId');
yourDiv.appendChild(yourSpan);

yourSpan.onmouseover = function () {
    alert("On MouseOver");

}

and for html I have
<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.</div>
<br>
<div id="divideTranscript" class="button">&nbsp;Transform the
Transcript!&nbsp; </div>T

I need the span creation inside the loop,
I need to create a span, add the class and id attribute (which is different for each word - it includes the index of the array (i)) to the span element, add the word inside the span, add mouseover/mouseout event listeners to the span, add the span to the original div.br mode="hold" />Can anybody help me its not much I just am not sure what to do and dont want to mess up what I have
Posted

1 solution

So make a copy of your whole project (I keep a folder under my Projects folder called "AABackups" for just this purpose) and try making the changes. If they work, fine - carry on. If they don't try to fix them. Remember at all times that you can "abandon ship" and copy your backup back to get back to working code before you started changing it, so you can;t make a "fatal" mistake - you can "throw away" rubbish and restart.

The best way to learn is to try it yourself and (if necessary) make mistakes: not to look at what someone else has done! :laugh:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900