-1

Chrome console is telling me that the following is missing a bracket:

Uncaught SyntaxError: missing ) after argument list

Here is my javascript:

<script type="text/javascript">

    $(document).ready(function(){

        $(document).on('change', 'input[type='file']', function() { 
      
        });

    });

</script>

Any thoughts as to why? Thank you!

Jason Howard
  • 1,464
  • 1
  • 14
  • 43
  • **'input[type="file"]'** single quote inside single quote causing error change with double quote or use slash – Hitesh Tripathi Jun 26 '20 at 04:30
  • Does this answer your question? [SyntaxError: missing ) after argument list](https://stackoverflow.com/questions/18931344/syntaxerror-missing-after-argument-list) – ABGR Jun 26 '20 at 05:01

3 Answers3

2

Try this: Should work just fine.

<script type = "text/javascript" >

  $(document).ready(function() {

      $(document).on('change', 'input[type="file"]', function() { 
        //Do something here
     });

  });

</script
Always Helping
  • 14,316
  • 4
  • 13
  • 29
2

Just need to close single quotes properly. Replace this:

'input[type='file']'

with this:

'input[type="file"]'

This happens when we use quotes inside quotes and we don't escape the inner quote or use a different quote instead like:

General Issue:

const text = 'input[type='file']'
console.log(text)

Solution #1: (Using double quote instead of single qoute for the inner string)

const text = 'input[type="file"]'
console.log(text)

Solution #2: (Excape the quote using \ before the qoute)

const text = 'input[type=\'file\']'
console.log(text)
palaѕн
  • 72,112
  • 17
  • 116
  • 136
2

I think your problem is in the 'input[type='file']'.

file should have double quotes, as the single quotes terminate the string, and chrome generates an unrelated error because that's what chrome does.

'input[type="file"]' should fix the problem

Ian Swift
  • 69
  • 1
  • 10