Search code examples
javascriptdomprototypejs

Replacing a Classed Element's Content (without an ID)


So I've managed to get stuck using Prototype for a Project, and so far I can't stand it.

All I want to do, is replace a title within a very specific place - it has no ID and I can't change the HTML, since it's not hosted by me.

Event.observe(window, 'load', function() {
    $$('#page #container .content .frame .entry h3.entry-title').update('Hello');
    $$('#page #container .content .frame .entry h3.entry-title').innerHTML;
});

Nothing happens with the script above, yet I know Prototype can pick up the <h3 class="entry-title"> because document.title = $$('#page #container .content .frame .entry h3.entry-title').length; displays 1.

What am I missing here?


Solution

  • try

    $$('#page #container .content .frame .entry h3.entry-title')[0].update('Hello');
    

    Your selector return value seems to be a prototype object/array. Catch the first entry with [0] and apply update().