Question:
Why does a jquery .click event handler for a select dropdown work fine in IE and Firefox, but not Chrome?
Details:
I can't get the .click event handler to activate with Chrome, but it works just fine with IE and Firefox. In IE and Firefox, when selecting "opt1" in the dropdown, an alert box is displayed. In Chrome, the alert("Hello");
statement is never even parsed. I'm running Win7. I've looked through the JQuery API documentation, but with no luck. Here's the code:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script src="jquery-2.1.1.min.js"></script>
<script src="ChromeTest.js"></script>
</head>
<body>
<select>
<optgroup label="Some">
<option id="opt1">1</option>
<option id="opt2">2</option>
</optgroup>
</select>
<input type="text" id="inputTest1" />
</body>
</html>
...with the following js to support:
// JavaScript source code
$(document).ready(function () {
var showArea = $("#inputTest1");
$('#opt1').click(function () {
alert("Hello");
});
});