<!DOCTYPE HTML>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<style>
body {
margin: 0px;
padding: 0px;
}
#myCanvas
{
background-color: blue;
}
.garagedoorthumbnail:hover
{
border: 1px solid green;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="540" height="305"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var imageObj = new Image();
imageObj.onload = function() {
context.drawImage(imageObj, 0, 0);
};
imageObj.src = 'backgroundgaragedoor.png';
$( ".garagedoorthumbnail" ).click(function() {
console.log("hello");
alert( "Handler for .click() called." );
});
</script>
<div id="doorgallary">
<p class="garagedoorthumbnail" src="garagedoor-beadedpanel.png">aaa</p>
<img class="garagedoorthumbnail" src="garagedoor-beadedpanelclassic.png" />
<img class="garagedoorthumbnail" src="garagedoor-beadedpaneltrifold.png" />
<img class="garagedoorthumbnail" src="garagedoor-beadedpaneltrifoldstockton.png" />
</div>
</body>
</html>
click 函数根本没有触发。我将一个更改为一个段落,看看它是否可能是元素。我已经多次使用 click 但这次它没有触发,我还没有看到有什么问题......