javascript not changing the text color -
i have function want change font color of user entered string if equal word located in array.. far when step through it says changes font color never updates screen , don't know why. here have far
function getlastword() { var input = document.getelementbyid("my_text"); //var input = document.getelementbyid(textarea.value); //var linein = document.getelementbyid(my_text).innerhtml; var inputvalue = input.value; var lastwordtyped var changecolorofword; if (input == null) { input == " "; } //lastwordtyped = input.substr(input.trim().lastindexof(" ") + 1); lastwordtyped = inputvalue.substr(inputvalue.trim().lastindexof(" ") + 1); if (input != null) { (var = 0; < reservedkeywords.length; i++) { if (reservedkeywords[i] === lastwordtyped) { lastwordtyped = lastwordtyped.fontcolor("blue"); my_text.replace(inputvalue, lastwordtyped); } else { } } } }
i see 2 issues code far.
you using 'fontcolor("blue")' parameter on lastwordtyped. proper syntax change color
element.style.color="#ccc".you need wrap last typed word in span can target , apply color word.
Comments
Post a Comment