<分区>
<分区>
Possible Duplicate:
Why don't jQuery works in Microsoft Visual Studio 2010?
我们已经创建了一个 web Visual Studio 2010 MVC 2 Web 元素,现在想要使用 jQuery 添加菜单和图像幻灯片的样式。但是当我们添加 jQuery 脚本文件时,Visual Studio 会返回一些错误。我们已经正确地给出了链接 jQuery 文件的先决条件。但错误仍然存在..
// code that we have used in jQuery //
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);
});
// code in view master page //
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/NIPL.css" rel="Stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/jquery-1.5.1.min.js") %>" type="text/javascript"></script>
<script src="../../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/SlideShow.js") %>" type="text/javascript"></script>
最佳答案
当您创建一个新的 MVC2 元素时,您将拥有一个名为 Script
的文件夹其中有 jquery。很有趣的是你没有这些脚本。
通过拖放 jquery 文件复制到 Scripts
文件夹并复制 CSS 文件到 Content
文件夹(不在 Script
内)
在Content
文件夹,你会看到 Site.css
文件。您必须在此处放置 CSS 文件。
通过 <link href=...
包含这些 CSS 文件在 Site.Master 文件中,在标题部分。
还有来自 Scripts
的 javascript 文件文件夹。
关于jquery - 如何在 Visual Studio 2010 MVC 2 Web 元素中添加 jQuery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8785195/