0

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?

2
  • 4
    missing function() i.e. $(document).ready(function(){ ... }) Commented Apr 21, 2017 at 10:03
  • Yep, that's it! I was completely blind-sided... Add it as an answer and I'll accept it. Commented Apr 21, 2017 at 10:06

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

You are missing function

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.