javascript - Code updates color but not the actual text? -


this chunk of code have updates color of text not actual text...

var lastwordtyped; var ele = document.queryselector("#my_text"); //code //... lastwordtyped = capitalizefirstletterofkeyword(lastwordtyped); lastwordtyped = lastwordtyped.fontcolor("blue"); ele.innerhtml = lastwordtyped;   function capitalizefirstletterofkeyword(keyword) {          var word;         word = keyword.charat(0).touppercase() + keyword.slice(1);         return word;     } 

when step through it, recognizing new string should doesnt update actual text new string, change color. can provide me reason why won't update it?

you haven't declared lastwordtyped, capitalizefirstletterofkeyword() gets 'undefined' input.

working demo here: http://jsfiddle.net/yc4mvm1n/1/

var lastwordtyped = "newword"; var ele = document.queryselector("#my_text");  lastwordtyped = capitalizefirstletterofkeyword(lastwordtyped); lastwordtyped = lastwordtyped.fontcolor("blue"); ele.innerhtml = lastwordtyped;  function capitalizefirstletterofkeyword(keyword) {         var word;         word = keyword.charat(0).touppercase() + keyword.slice(1);         return word;     } 

Comments

Popular posts from this blog

python - Referencing Data From a 2D Histogram -

c# - Derived UserControl layout resets after build -

php - MySQL LIMIT results with INNER JOIN with more than 2 tables -