views:

44

answers:

2

I have a group of buttons on my web page which all have an id that end with the text "EditMode".

I'm using jQuery to assign an event to like so

$('[id $=EditMode]').click(editHandler);

However now I want to prefix the id with a name (which I will know in advance) so the id would be "aName+someotherstuff+EditMode". How do I alter the above expression so I match on aName AS WELL as editMode?

+4  A: 
$('[id ^=aName][id $=EditMode]')
chaos
+1  A: 

Alternatively, you can use the "add()" function for readability, but I would recommend Chaos's method:

$("[id ^=aName]").add("[id $=EditMode]")
Richard Clayton