I have to create:
- 1
<input type="text"> - 1
<textarea> - 1
<div> - 1
<button>
I have to fill the div with the textarea's content but if the content contains the input's string, I have to color it with <span>.
For example:
If the input contains "is" and the textarea contains "this is a beautiful day", I should put the following text in the div "this is a beautiful day" and color every time that the "is" string appears.
I should use indexOf() and a loop.
I have this:
var a = $("#inp1").val();
var b = $("#txt").val();
var x = b.indexOf(a);
if (x > -1)
bina. You can split your string and recreate it, yourbwrapped in a styled span. w3schools.com/jsref/jsref_substring.asp