Search code examples
prototypejs

prototype get inner html of multiple classes


I am new to prototype and finding it a lot more difficult than jquery. All i want to do is get the inner html of various classes.

$$('.book').each(function() {
    var msg = this.down(".information"); 
    alert(msg.innerHTML);
    //new Tip(this, msg.innerHTML, {stem: 'topLeft',  hook: { tip: 'topLeft', mouse: true }, offset: { x: 14, y: 14 }});
});

I'm trying to create tooltips for multiple items, but I'm not even getting the alert.


Solution

  • The this variable is not pointing to the element you're iterating over in Prototype, you have to explicitly use a parameter:

    $$('.book').each(function(book) {
        var msg = book.down(".information"); 
        alert(msg.innerHTML);
    });