Loop nos objetos HTML com prototype

<br />
&lt;html&gt;<br />
&lt;header&gt;<br />
 &lt;script src=&quot;prototype.js&quot;&gt;&lt;/script&gt;<br />
&lt;/header&gt;<br />
&lt;body&gt;<br />
 &lt;input type=&quot;checkbox&quot; id=&quot;che1&quot; name=&quot;che&quot; /&gt; 1 &lt;br /&gt;<br />
 &lt;input type=&quot;checkbox&quot; id=&quot;che2&quot; name=&quot;che&quot; /&gt; 2 &lt;br /&gt;<br />
 &lt;input type=&quot;checkbox&quot; id=&quot;che3&quot; name=&quot;che&quot; /&gt; 3 &lt;br /&gt;<br />
 &lt;input type=&quot;checkbox&quot; id=&quot;che4&quot; name=&quot;che&quot; /&gt; 4 &lt;br /&gt;<br />
 &lt;input type=&quot;checkbox&quot; id=&quot;che5&quot; name=&quot;che&quot; /&gt; 5 &lt;br /&gt;<br />
 &lt;input type=&quot;button&quot; value=&quot;Marcar&quot; onclick=&quot;fnMarcar(true);&quot; /&gt; &lt;br /&gt;<br />
 &lt;input type=&quot;button&quot; value=&quot;Desmarcar&quot; onclick=&quot;fnMarcar(false);&quot; /&gt; &lt;br /&gt;<br />
 &lt;script type=&quot;text/javascript&quot;&gt;<br />
 function fnMarcar(tipo){<br />
 $$('input').each(function(e){<br />
 if(e.type == 'checkbox' &amp;&amp; e.name == 'che'){<br />
 e.checked = tipo;<br />
 }<br />
 });<br />
 }<br />
 &lt;/script&gt;</p>
<p>&lt;/body&gt;<br />
&lt;/html&gt;<br />

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

This site uses Akismet to reduce spam. Learn how your comment data is processed.