Is there a way to refactor something like this:
$("input[name='InputName1'],input[name='InputName2']").val("");
into something like this:
$("input[name='InputName1|InputName2']").val("");
Essentially, is it possible to select elements based on a set of attribute values without the repetitive parts of the selector?
The first version you have is about as short as it gets, ignoring the special case:
I say special case because if you want arbitrary names it’s not like they’re going to have that convenient prefix all the time (I would assume).
Generally I try and avoid attribute selectors. I usually feel like I’ve failed if I have to resort to them. Try and use marker classes where possible so instead of:
you give them both a class of “reset” and do: