title: How do I use jQuery to pull a name attribute from a SPAN element?
body: <p>I have an HTML file that I'm scraping with a greasemonkey script in which I'm using jQuery.  </p>
  
  <p>The HTML page is very long, but I have a number of <code>&lt;span&gt;</code> elements throughout the page. </p>
  
  <p>Let's assume that the elements look like this:</p>
  
  <pre><code>&lt;span id="spnMX45" name="spnMX45" &gt;16&lt;/span&gt;
  &lt;span id="spnMX46" name="spnMX46" &gt;10&lt;/span&gt;
  &lt;span id="spnMX47" name="spnMX47" &gt;11&lt;/span&gt;
  &lt;span id="spnMX48" name="spnMX48" &gt;5&lt;/span&gt;
  </code></pre>
  
  <p>There are two values that I need from each of these elements: I need the number that comes after the "spnMX" and the text of the span. </p>
  
  <p>I'm going to populate an array with these values and send them off for processing. The majority of this I can do, but grabbing the <code>name</code> or <code>id</code> attributes have been a problem.</p>
  
  <p>Here's what I have at the moment:</p>
  
  <pre><code>// Grab Max Points for assessments
  var maxPointsArray = $("span[id^=spnMX]").map(
      function(data){
      arr = [this.Attr('name')];
      return arr;
      }
  );
  
  console.log(maxPointsArray.length);  // yields:  9 &lt;--actual number of span elements in test html
  console.log(maxPointsArray);  // yields:  9 undefined objects
  </code></pre>
  
  <p>I've tried:</p>
  
  <pre><code>arr = [this.name];
  arr = this.name;
  arr = [this.attr('name')];
  arr = this.Attr('name');
  </code></pre>
  
  <p>I just can't seem to get it.  Are span attributes unable to be grabbed?  I doubt it, but I can't figure this one out.  I've done this exact thing with several different input-type elements successfully.  I can't grab the <code>text()</code> of this object successfully, but I can't seem to get that dang name, or id even, attribute.</p>