Home jquery I don’t understand why missing) after argument list

I don’t understand why missing) after argument list

Author

Date

Category

String:

$ ('# contact-bottom'). css ('background': '# 3F51B5 url (' + ' img / check.png '+') no-repeat 50% 50% ');

Error:

Uncaught SyntaxError: missing) after argument list

The entire piece of code in ajax:

$. ajax ({
          type: "POST", // Submission method
          url: "mail.php", // path to the sender's php file
          data: form_data,
          success: function () {
            console.log ("Message successfuly send");
            $ ("# mail-button"). detach ();
            $ ('# contact-bottom'). css ('background': '# 3F51B5 url (' + 'img / check.png' + ') no-repeat 50% 50%');
          }
        });

Answer 1, authority 100%

Missing brackets {} required to create an object – argument to the function $ (). css :

$ ('# contact-bottom'). css (
 {'background': '# 3F51B5 url (' + 'img / check.png' + ') no-repeat 50% 50%'}
);

or replace : with , :

$ ('# contact-bottom'). css (
 'background', '# 3F51B5 url (' + 'img / check.png' + ') no-repeat 50% 50%'
);

http://api.jquery.com/css/


Answer 2

The ('string': 'string') constructs in JS raise questions – why a colon?
Out 2:

  1. Turn this into an object where : is legal:
    ({'background': '# 3F51B5 url (' + 'img / check.png' + ') no-repeat 50% 50%'}); .

  2. Either abandon this construction (in jQuery , you can set one rule
    like this: ('background', '# 3F51B5 url (' + 'img / check.png' + ') no-repeat 50% 50%'); ).

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions