Group multiple or statements within an IF in javascript
- by nick
The following code works:
$(".valClear").each(function () {
if ($(this).val().indexOf(".png") == -1) {
$(this).val('');
}
});
However this doesn't (the value is removed even if it contains .png or .jpeg), what am I doing wrong?
$(".valClear").each(function () {
if (($(this).val().indexOf(".png") == -1) || ($(this).val().indexOf(".jpeg") == -1)) {
$(this).val('');
}
});