Select HTML elements by variable substring of a property
<p>I have several groups of elements, each group of which is related to a particular number.  I want to add a mouseover to each element that adds a class to all the elements in its group, and a mouseout that removes that class.  jQuery's attributeStartsWith selector works great for this as long as I give it a string literal, but I'm trying to write a function to do this with any group, so I need the selection to take a parameter as the substring.  Is there a way to do this with attributeStartsWith, or should I try some other technique?</p>

<p>Here's what I have that works:</p>

<pre><code>function highlight(numberString)
{ $('p[id^="321"]').addClass("highlighted");  }
</code></pre>

<p>I need to replace "321" with the parameter numberString.  The following doesn't seem to do that.  I gather that's because attributeStartsWith treats numberString as an unquoted single-word string and not a variable name.</p>

<pre><code>function highlight(numberString)
{ $('p[id^=numberString]').addClass("highlighted");  }
</code></pre>
