Modifying a class name through reference to the parent with jQuery
<p>I had some help and some suggestions on how to remove a class name. </p>

<p><a href="http://stackoverflow.com/questions/9257348/how-can-i-remove-a-class-from-an-element-with-jquery-based-on-some-characters-of/9257394#9257394">Previous answer</a></p>

<p>These worked in fiddle but my application is just a bit different. I have the following:</p>

<pre><code>&lt;span id="refType_1" class="refType indent_02"&gt;Link Header&lt;/span&gt;
</code></pre>

<p>My javascript looks like this:</p>

<pre><code>if (action == "Edit") {
   var parent = linkObj.closest("tr");
   parent.find(".refType").html($("#Type :selected").text());  // 1
   parent.find(".refType").className.replace(/indent_\d+($|\s)/, "xxx"); 
   parent.find(".refType").trim(this.className.replace(/(^|\s)indent_\d+($|\s)/, " "));
</code></pre>

<p>I tried the last two ways of replacing the class name with "" but both give me an error. For example the last method gives the following:</p>

<pre><code>SCRIPT438: Object doesn't support property or method 'trim'
</code></pre>

<p>I think I'm 99% towards getting it working but would appreciate advice. I tried a few different ways so far and it still does not work. </p>

<p>Please note the line with comment // 1 does work. I can change the contents of the span as needed. What does not work is:</p>

<pre><code>parent.find(".refType").className.replace(/indent_\d+($|\s)/, "xxx");   or
parent.find(".refType").trim(this.className.replace(/(^|\s)indent_\d+($|\s)/, " "));
</code></pre>

<p>These are my two different attempts to get the text indent_xx to be removed from the span.</p>
