1

I've recently encountered an error while trying to run a function with more than one argument.

<button type = "button" id = "clickmepls" onclick = killButton("clickmepls", "grave1")> Click me please </button>

The function's definition is the following:

function killButton(buttonname, graveID){
   /* some code */
}

When the script is run, I'm given the following error: https://i.sstatic.net/dWpvO.png

It happens whenever there is more than one argument in the function - the first one is shown in the error window, the arrow always points at what (doesn't) come after.

What is the reason behind this?

2 Answers 2

1

You forgot quotes.

<button type = "button" id = "clickmepls" onclick = "killButton('clickmepls', 'grave1');"> Click me please </button>
Sign up to request clarification or add additional context in comments.

Comments

0

Attribute values with spaces in them must be quoted, otherwise the space terminates the attribute value in the middle of the JavaScript statement.

onclick="killButton('clickmepls', etc… "

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.