【发布时间】:2011-11-25 02:23:06
【问题描述】:
我是 JQuery 新手,正在尝试使用我在网上找到的插件来翻转图像。我正在使用可用的插件 http://www.hieu.co.uk/blog/index.php/imageswitch/
我在我的asp.net项目中添加了js库,并使用了库中提到的flipOut方法。
<script type="text/javascript">
var ImgIdx = 2;
var ImgName = "slash";
$(document).ready(function () {
$("img#image").click(function () {
if (ImgIdx > 4)
ImgIdx = 2;
ImgName = ImgName + ImgIdx + ".jpg";
ImgIdx = ImgIdx + 1;
if ($(this).hasClass("fadeout")) {
// $(this).fadeTo('slow', 1);
$(this).toggleClass("fadeout");
$(this > img).ImageSwitch({ Type: "FlipIn", NewImage: "slash2.jpg" });
}
else {
$(this).fadeTo('slow', 0.5);
// FlipIn
$(this).toggleClass("fadeout");
$(this).ImageSwitch({ Type: "FlipIn", NewImage: "slash3.jpg" });
}});});
</script>
<html><body>
<asp:Image ID ="image" ImageUrl= "slash2.jpg" runat="server"></body></html>
问题是:当我执行第一次点击时这工作正常,但在连续点击时没有任何反应。我试图将警报消息放在点击事件中,但由于第二次和连续的点击没有触发,甚至警报消息也没有出现。 我正在使用 ASP.NET 3.5。
【问题讨论】:
-
我对 ASP 不熟悉,但是等待
runat="server"的意思。为了让 jQuery 工作,必须在文档中创建 DOM 元素。
标签: jquery asp.net jquery-ui jquery-plugins