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

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -