Group multiple or statements within an IF in javascript

Posted by nick on Stack Overflow See other posts from Stack Overflow or by nick
Published on 2010-12-25T23:41:44Z Indexed on 2010/12/25 23:54 UTC
Read the original article Hit count: 126

Filed under:
|

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('');
        }
    });

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery