Sebastian Plasschaert
Sebastian Plasschaert

Reputation: 304

jQuery onChange: Uncaught SyntaxError: Unexpected string

I'm trying out a javascript in my rails with jQuery setup, but I'm getting an error: "Uncaught SyntaxError: Unexpected string"

$(document).ready({
  $('#pitch_name').on('change',function() {
    $('#edit_pitch_name').remove();
  });
});

Any ideas on what I'm missing here?

Upvotes: 0

Views: 353

Answers (2)

Ali Mehdi
Ali Mehdi

Reputation: 924

You are missing function

$(document).ready(function(){
  $('#pitch_name').on('change',function() {
    $('#edit_pitch_name').remove();
  });
});

Upvotes: 1

Rana Ghosh
Rana Ghosh

Reputation: 4674

You have written a wrong syntax of document.ready missing of function(), you should use below code::

$( document ).ready(function() {
  // Your code
});

Official documentation:: Link

Upvotes: 2

Related Questions