這是我的<head>
。點擊我的圖片時,jQuery點擊事件未被觸發
<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Paytone+One' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Coda+Caption:800' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css' />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="@Url.Content("~/Scripts/ddpowerzoomer.js")" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function ($) { //fire on DOM ready
$('#mainproductpicture').addpowerzoom({
defaultpower: 2,
powerrange: [2, 5],
largeimage: null,
magnifiersize: [200, 200] //<--no comma following last option!
})
})
$('#smallpictureone').click(function() {
alert('Handler for .click() called.');
});
$('#smallpicturetwo').click(function() {
alert('Handler for .click() called.');
});
$('#smallpicturethree').click(function() {
alert('Handler for .click() called.');
});
$('#smallpicturefour').click(function() {
alert('Handler for .click() called.');
});
$('#smallpicturefive').click(function() {
alert('Handler for .click() called.');
});
</script>
</head>
而我的HTML:
<div id="auctiondetails">
<img id="mainproductpicture" src="../../Content/Images/product2.JPG" alt="test" />
<img id="smallpictureone" src="../../Content/Images/product1.JPG" />
<img id="smallpicturetwo" src="../../Content/Images/product2.JPG" />
<img id="smallpicturethree" src="../../Content/Images/product3.JPG" />
<img id="smallpicturefour" src="../../Content/Images/product4.JPG" />
<img id="smallpicturefive" src="../../Content/Images/product5.JPG" />
</div>
當點擊任何的應該是有線事件的圖像,沒有任何反應。有任何想法嗎?
你有你的jQuery(文件)後缺少分號...電話。 –
@ar:錯過了,謝謝。 :) –