I’m using jQuery 1.6.4 in a jsp and I have a function that filters out a select element on a change event, which works fine. I also want to filter out a save button as well in the same function.
It seemed difficult to try and pinpoint the buttons as there are more than one, so I opted for a class to distinguish them. Here is what I have so far:
$(function(){
$(':input:not("select")').change(function(){
$(':input:submit:not(".saveButton")'){
// Do something here.
}
}); ...
Here are the buttons. It’s Struts2 tags:
<td>
<s:submit action="<actionName>" cssClass="saveButton" value="Save" />
</td>
<td>
<s:submit action="<anotherActionName>" value="Cancel" />
</td>
but when I run this it’s not working at all with the extra input. I’m not sure if this is correct syntax or if it’s the best approach either? Any ideas on this?
This is what I found that worked, based on the answer below:
$(function(){
$(':input:not("select")').change(function(){
if($(':submit:not(".saveButton")')) { ...
UPDATED: you were making life too complicated, just select the cancel button if there are only two of them.