Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Ruby と Hpricot gem を使用して HTML タグにカスタム属性を追加する方法を誰か説明してもらえますか?
次のようなタグがあります。
<div class="test" id="tag1" style="">
「Readable=0」というカスタム整数属性を追加したいので、次のようになります。
<div class="test" id="tag1" style="" readable=0>
これは可能ですか?
試す:
element.set_attribute "readable", "0"
またはあなたが持っている場合Hpricot::Elements:
Hpricot::Elements
elements.set "readable", "0"