title: Change style of multiple elements
body: <p>I'm trying create a loop (or use <code>.each</code>) to change the <code>style:display</code> property of many DOM elements.  My initial thought was to use <code>getElementsByName</code> to select all of the elements that I named <code>ptext1</code>:</p>
  
  <pre><code>&lt;p id="ptext0"name="ptext"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
  &lt;p id="ptext1"name="ptext1"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
  &lt;p id="ptext2"name="ptext1"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
  &lt;p id="ptext3"name="ptext1"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
  &lt;p id="ptext4"name="ptext1"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
  &lt;p id="ptext5"name="ptext1"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
  &lt;p id="ptext6"name="ptext1"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
  </code></pre>
  
  <p>using</p>
  
  <pre><code> var TextElements = document.getElementsByName("ptext1");
  </code></pre>
  
  <p>To make an object/array of all of the elements with the name <code>ptext1</code></p>
  
  <p>But I could not get that method working correctly so I moved onto the <code>.each</code>.</p>
  
  <p>Both </p>
  
  <pre><code>$.each(TextElements, function (index) {
      this.style.display="none";
  });
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$('td[name=ptext1]').each(function (index) {
      this.style.display="block";
  });
  </code></pre>
  
  <p>Didn't seem to work properly (I've been testing whether it runs using alerts).  </p>
  
  <p>Now if anyone can see where my mistake is or suggest a better method I am all ears.  This SHOULD be a simple operation but for some reason each time I try, it fails.</p>
  
  <p>Edit:
  <code>$('p[name=ptext1]').hide()</code> and <code>$('p[name=ptext1]').show()</code>
  are working except .hide() also hides the line above the ones I would like to hide,</p>
  
  <pre><code>&lt;p id="ptext0"name="ptext"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.
          &lt;/p&gt;
  </code></pre>
  
  <p>Each line has a different id tag, but I am trying to use the name tag to keep track of which ones I would like to hide, yet the line that should remain (name="ptext") also hides.</p>