Elijah Corleone
Elijah Corleone

Reputation: 13

Syntax javascript error missing ) after argument list in javascript

I get the Syntax missing ) error

$(document).ready(function changeText() {

    var p =     document.getElementById('bidprice');

    var btn = document.getElementById('paybtn');

    var txt = document.getElementById('theText');
    btn.onclick( p.textContent = txt.value; );

});             

what exactly is the wrong thing I have tried looking at my syntax seems okay

Upvotes: 0

Views: 72

Answers (2)

Adam Azad
Adam Azad

Reputation: 11297

You have a ;, and onclick property should be a function.

btn.onclick( p.textContent = txt.value; );
                                      ^

Remove it, and wrap everything in a function:

btn.onclick = function(){
    p.textContent = txt.value;
};

Upvotes: 2

Kit
Kit

Reputation: 752

I believe it is because you are trying to name your function in the parameter passed into 'ready'.

First line should be:

$( document ).ready(function() {

Upvotes: 0

Related Questions