jQuery selector for matching at start AND end of ID?
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?
Solution 1:
$('[id ^=aName][id $=EditMode]')
Solution 2:
Alternatively, you can use the "add()" function for readability, but I would recommend Chaos's method:
$("[id ^=aName]").add("[id $=EditMode]")