最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - this.innerHTML in Prototype - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question edited Feb 11, 2016 at 8:08 bpoiss 14k4 gold badges37 silver badges49 bronze badges asked Sep 3, 2011 at 2:31 Danny_JorisDanny_Joris 3996 silver badges17 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Try this:

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

IE shows very poor performance when replacing plex DOM trees. In such cases remove the inner DOM before updating:

$$('label.currency').invoke('childElements').invoke('invoke','remove');

If it's one single Element you can say:

$('elementID').childElements().invoke('remove');
发布评论

评论列表(0)

  1. 暂无评论