【发布时间】:2012-01-06 12:07:05
【问题描述】:
我在 MS Visual Studio 2010 中创建了一个 ASP.NET MVC 2 Web 应用程序。现在我需要使用 JQuery 为其添加样式。为了在 div 中创建图像幻灯片,我编写了一个 JQuery 文件并尝试了将其与我的查看母版页链接。但是发生的情况是,当我尝试运行我的项目时,Visual Studio 告诉“Microsoft JScript 运行时错误:'jQuery' 未定义”。你们中的任何人都可以帮助我解决这个问题吗? ...谢谢:)
here's the code I have given within my jQuery
/*Coding : Nidhin & Eldhose*/
function slideSwitch() {
var $active = $('#Left_Image DIV.active');
if ($active.length == 0) $active = $('#Left_Image DIV:last');
// use this to pull the divs in the order they appear in the markup
var $next = $active.next().length ? $active.next()
: $('#Left_Image DIV:first');
// uncomment below to pull the divs randomly
// var $sibs = $active.siblings();
// var rndNum = Math.floor(Math.random() * $sibs.length );
// var $next = $( $sibs[ rndNum ] );
$active.addClass('last-active');
$next.css({ opacity: 0.0 })
.addClass('active')
.animate({ opacity: 1.0 }, 1000, function () {
$active.removeClass('active last-active');
});
}
$(function () {
setInterval("slideSwitch()", 5000);
});
【问题讨论】:
-
请检查您是否在该页面上包含了 jQuery 库。
-
使用谷歌浏览器开发者工具。太棒了。在谷歌浏览器中按 F12 并转到控制台选项卡。如果您收到任何脚本错误,您将看到。他们会指导你。
标签: jquery css asp.net-mvc