Reputation: 753
I would like to pass a string as a parameter of the following:
<div id="menubutton1" class="menubutton lightbox" onclick="lightbox(1000, 410, hello)">
How would I make "hello" become a parameter. The integers pass without problem.
Thank you.
Upvotes: 1
Views: 3851
Reputation: 85
Use single quotes around your string like so:
<div id="menubutton1" class="menubutton lightbox" onclick="lightbox(1000, 410, 'hello')">
Upvotes: 2
Reputation: 1055
You have to add quotes to the string parameter:
<div id="menubutton1" class="menubutton lightbox" onclick="lightbox(1000, 410, 'hello')">
will work.
Upvotes: 1
Reputation: 386
The content of the onclick property is handled as Javascript
<div onclick="HERE IS JAVASCRIPT"></div>
So you should use 'hello'
while you are using double quote for onclick property,
or "hello"
else using single quote.
Should either use one of it to represent that hello
is a string, not a variable name.
Upvotes: 0
Reputation: 834
Add a '
before hello and a '
after hello:
onclick="lightbox(1000, 410, 'hello')"
Upvotes: 1