Setting the class of a div based on the contents of a link using jQuery
<p>This is probably pretty simple but I can't figure it out! I need to parse the text inside an  tag and set the class of a div based on it's contents. Here's what I need to do:</p>

<pre><code>&lt;div id="targetDiv"&gt;  Content Here  &lt;/div&gt;
&lt;a href="/BookingRetrieve.aspx?ID=6463"&gt;Open House - October 21, 2010&lt;/a&gt;
&lt;a href="/BookingRetrieve.aspx?ID=6463"&gt;Meeting - October 21, 2010&lt;/a&gt;
</code></pre>

<p>I need to set the class of the first div to either "OpenHouse" or "Meeting" based on the contents of the text string inside the  tag. (Note: only one would be showing. I'm including both only for reference).</p>

<p>So if this were showing on the page:</p>

<pre><code>&lt;a class="linkText" href="/BookingRetrieve.aspx?ID=6463"&gt;Open House - October 21, 2010&lt;/a&gt;
</code></pre>

<p>The div would be </p>

<pre><code>&lt;div id="targetDiv" class="OpenHouse"&gt;  Content Here  &lt;/div&gt;
</code></pre>

<p>Here's the jQuery:</p>

<pre><code>if($(".linkText").val().indexOf("House") == 0){$('#targetDiv').addClass('OpenHouse');};
</code></pre>

<p>For some reason this does not work. Any help is appreciated!</p>
