title: Javascript Regex: how to replace just the class of attribute for any tr?
body: <p>I have the following HTML code:</p>
  
  <pre><code>&lt;tr id="1774" class="XXX"&gt;&lt;td&gt; &lt;span class="YYY"&gt;
  
  Element 1&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr id="1778" class="XYZ"&gt;&lt;td&gt; &lt;span class="ZZZ"&gt;Element 2
  &lt;/span&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  </code></pre>
  
  <p>I want to replace all the class attributes (just for &lt;<strong>tr</strong>> s) but not for &lt;<strong>td</strong>> s.
  (<strong><em>that would be XXX and XYZ</em></strong>). The replacement would be: <strong><em>XXX_suffix, XYZ_sufix</em></strong></p>
  
  <p>Here is my workaround, but it replaces all the class attributes (in  elements too!).</p>
  
  <pre><code>var htmlBlock= "&lt;tr id="1774" class="XXX"&gt;&lt;td&gt; &lt;span class="YYY"&gt;...&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;";
  htmlBlock+="&lt;tr id="1778" class="XYZ"&gt;&lt;td&gt; &lt;span class="ZZZ"&gt;...&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;";
  
  htmlBlock= htmlBlock.replace(/class="\s*(\w*)/g, "class=\" $1 " + _suffix);
  </code></pre>
  
  <p>But how can I replace <em>just the tr class attribute</em> ??</p>
  
  <p>Is there another way in jQuery ??</p>