jquery - Javascript - how to update elements inner html? -
i have this:
var stopwatch = function (item) { window.setinterval(function () { item.innerhtml = myinteger++; }, 1000); } this code supposed display myinteger, not updating values of item. why (item div text inside)?
there lot of reasons (we need see more of code), here working example:
var myinteger = 1, stopwatch = function (item) { window.setinterval(function () { item.innerhtml = myinteger++; }, 1000); } stopwatch(document.queryselector('div')); important changes:
- calling
stopwatch(you this) - innerhtml+innerhtml(the case matters). won't error settinginnerhtml; set property , won't notice anything.- initialize
myinteger.
Comments
Post a Comment