 <pre><code>$('div[id^="sameId_"]').click(...) </code></pre> <p>Demo: <a href="http://jsfiddle.net/kpcxu/">http://jsfiddle.net/kpcxu/</a></p> <p>For more info, see <a href="http://api.jquery.com/attribute-starts-with-selector/">Attribute Starts With selector</a>.</p>