Before I explain my problem, I want to show you the process of my Javascript:
When you input a text in the input bar and press submit, the script creates a "div" and places that text in that newly created div and puts it into a permanent div (Div that already existed, and not created from javascript).
For example:
$(".list").append('<div class="woof">' + '<div class="box">' + toAdd + '</div>' + '</div>');
The newly created .woof and .box div's are placed into an already existing .list div
. The toAdd
is the text from the input value.
Simultaneously, Javascript inputs the toAdd
string into a variable containing an array (Ex: Var theArray = []
). After inputting several texts, the 'theArray' variable array becomes filled with strings (Ex: var theArray = ["Meow", "Cheeseburger", "Yes"]
) while--as previously stated--adding those string to the HTML (Ex: So, that means the HTML <div class='list'>
should also have "Meow", "Cheeseburger", etc). Then there is a script that creates a random number which randomly selects one of the strings from the array (Ex: The random number generated selects "Yes" from the array).
The problem I am having is creating a Javascript/Jquery that gets the results from the random generated number and finding it in the HTML. The script I created allowed me to successfully pick a string from the array, but I am trying to get that pick to become highlighted in the HTML list.
For example, the random generated number selects "Yes" string from the Array. I then want to create a script that finds the "Yes" in the HTML div, and highlight it (with CSS or etc) so the viewer can see that that String was chosen.
So, the problem I am having is the one above this sentence. I can't find a way to connect what the random number generated picked with the strings in HTML. Hopefully, this explains it.