Search code examples
javascriptprototypejsthis

this.innerHTML in Prototype


js code snippet that goes like this:

function currency_change(value) {

  // change all currencies on the page
  $$('label.currency').each(function() {

    this.innerHTML = value;

  });
  alert(value);

}

I know value is correct and I know I'm traversing over each label.currency class, but I can't seem to change the innerHTML values of these elements.

I googled like crazy, but I can't figure out how to do this. I suspect something is wrong with this.


Solution

  • Try this:

    $$('label.currency').each(function(element) {
        element.update(value);
    });