HTML:
<label name="table_id" for="1280461">Rock</label>
<label name="table_id" for="1291065">Paper</label>
これは機能しません:
$$('label[name="table_id"]').each(function(s){
console.log(s.for);
});
HTML:
<label name="table_id" for="1280461">Rock</label>
<label name="table_id" for="1291065">Paper</label>
これは機能しません:
$$('label[name="table_id"]').each(function(s){
console.log(s.for);
});
s.readAttribute('for');
for
は Javascript のキーワードです。s.for
" " 形式では使用できません。
DOM Element
のgetAttribute関数を使用します。
$$('label[name="table_id"]').each(function(s){
console.log(s.getAttribute('for'));
});
これに答えるフィドルを作成しました。これがあなたにとって意味があることを願っています。