Search code examples
javascriptprototypejs

Get a value of for in a label using prototype


HTML:

<label name="table_id" for="1280461">Rock</label>
<label name="table_id" for="1291065">Paper</label>

This doesn't work:

$$('label[name="table_id"]').each(function(s){ 
  console.log(s.for); 
});

Solution

  • s.readAttribute('for');
    

    See: http://prototypejs.org/api/element/readattribute