0

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

2 Answers 2

2

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;
};
Sign up to request clarification or add additional context in comments.

3 Comments

wait it doesn't persist thanks a lot , however the value retrived is empty is empty
@ElijahCorleone, you would need to create a fiddle to illustrate the issue :)
@ElijahCorleone, you can accept the answer if it helped
0

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() {

1 Comment

Nope. You can also do var outer=function inner (){} inner is just acessible inside of the code, making it possible to have anonymous recurisve functions, it doesnt matter if a function is anonymous or not, its always a function...

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.