Q:

Find an element that contains id of selector + text

I'm confused as to how I should go about doing this.
My page is using PHP to take product codes off a database and using them to generate ids for elements. For example: $("#touch-'.$productcode.'") and $("#popup-'.$productcode.'")
I need to make it so when an element is clicked on, jQuery will find an element in the document which contains the last 11 characters of the selector's id plus additional text.
e.g. the selector $(this) (which has a generated id of #touch-123-456-789) would get its own id, remove everything but the last 11 characters (the product code), append popup- to the beginning, and then find the element $("#popup-123-456-789") and perform an action.

A:

How about some thing like this..
<div class='touch' id='touch-123-456-789'> bla bla </div>

on your jquery
$('.touch').click(function(){
var id = $(this).attr('id');
id = id.substring(5);

$('#popup' + id).doSomething();

});

