jQuery - has class that starts with
<p>What would be the best way to get all divs that have any class that starts with <code>input</code>?  In other words, <code>a</code> and <code>b</code> should be returned from what's below, but not <code>c</code>.</p>

<pre><code>&lt;div id="a" class="input1 foo"&gt;&lt;/div&gt;
&lt;div id="b" class="foo input2"&gt;&lt;/div&gt;
&lt;div id="c" class="xinput3 foo"&gt;&lt;/div&gt;
</code></pre>

<p>The ostensible way, which surprisingly was accepted <a href="http://stackoverflow.com/questions/4165183/jquery-match-element-that-has-a-class-that-starts-with-a-certain-string">here</a>, is to do <code>$("div[class^='input']");</code> but of course that misses <code>b</code>.  And of course <code>$("div[class*='input']");</code> will give a false positive on <code>c</code>.</p>

<p>The best I could come up with was this monstrosity</p>

<pre><code>function getAllInputDivs() {
    return $("div").filter(function (i, currentDiv) {
        return $.grep($(currentDiv).attr("class").split(" "), function (val) {
            return val.substr(0, "input".length) === "input";
        }).length &gt; 0;
    });
}
</code></pre>

<p>Is there a cleaner way?  Here's a <a href="http://jsfiddle.net/KYx2Y/1/">working fiddle</a> of the above</p>
