Reputation: 43
Can someone please explain why am I not getting this alert message when clicked on the button? I just started learning HTML and this is the code given in my book which is supposed to work but it is not working when i execute it. What is the problem? I am using Mozilla Firefox Beta version.
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>This is a test page</title>
</head>
<body>
<h1>This is a test Paragraph</h1>
<button type="button"
onclick="alert('You've clicked me.')">Click me!</button>
</body>
Upvotes: -1
Views: 236
Reputation: 449
You need to change line
onclick="alert('You've clicked me.')">Click me!</button>
to
onclick="alert('You\'ve clicked me.')">Click me!</button>
Upvotes: 3
Reputation: 24526
You have a syntax error. You need to escape the apostrophe in "you've".
alert('You\'ve clicked me.')
Upvotes: 6