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.

  1. you using 'fontcolor("blue")' parameter on lastwordtyped. proper syntax change color element.style.color="#ccc".

  2. you need wrap last typed word in span can target , apply color word.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -