I have a jQuery hook-on that listens for a checkbox with the name wantProdTy that has the values “Mobile” or “Broadband”. How should i write this?
Checkbox with value “Mobile”:
$('input[type="checkbox"][name="wantProdTy"][value="Mobile"]').change(function() {
// do something
}
EDIT
Accepted answer:
$('input[type="checkbox"][name="wantProdTy"]').filter(function(){
return /(Mobile|Broadband)/i.test(this.value);
}).change(function() {
<% // check that the checkbox is checked %>
if($(this).is(':checked')) {
<% // check that mobile or broadband has not reached the maximum limit %>
maximumServiceLimitListener();
}
});
You could use
filter: