我正在尝试在我的项目中使用手风琴。据我了解,应该在布局页面中添加 javascript 链接,在索引页面中添加 javascript 代码,它必须在其中显示。但是浏览器说 $(#"accordion").accordion 不是一个函数。这是_Layout的代码。
@using kazwaySite
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width"
@Styles.Render("~/Content/themes/base/css", "~/Content/css")
@Scripts.Render("~/bundles/modernizr")
<link type="text/css" href="~/Scripts/css/ui-lightness/jquery-ui-1.8.22.custom.css" rel="stylesheet" />
<script type="text/javascript" src="@Url.Content("~/Scripts/js/jquery-1.7.2.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/js/jquery-ui-1.8.22.custom.min.js")"></script>
</head>
<body>
<header>
<div class="content-wrapper">
<div class="float-left">
<p class="site-title">@Html.ActionLink("Your logo here", "Index", "Home")</p>
</div>
<div class="float-right">
<section id="login">
@Html.Partial("_LoginPartial")
</section>
<nav>
<ul id="menu">
<li>@Html.ActionLink(Resources.mainPage , "Index", "Home")</li>
<li>@Html.ActionLink(Resources.aboutPage, "About", "Home")</li>
<li>@Html.ActionLink(Resources.productsPage, "Index", "Home")</li>
<li>@Html.ActionLink(Resources.capabilitiesPage, "Index", "Home")</li>
<li>@Html.ActionLink(Resources.newsPage, "About", "Home")</li>
<li>@Html.ActionLink(Resources.partnersPage, "Index", "Home")</li>
</ul>
</nav>
</div>
</div>
</header>
<div id="body">
@RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
<footer>
<div class="content-wrapper" >
<table >
<tr style="font-size:20px;font-weight:500;">
<td>@Html.ActionLink("О компании", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
<td>@Html.ActionLink("Возможности", "About", "Home")</td>
<td>@Html.ActionLink("Новости", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
</tr>
<tr style="font-size:12px;font-weight:500;">
<td>@Html.ActionLink("О компании", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
<td>@Html.ActionLink("Возможности", "About", "Home")</td>
<td>@Html.ActionLink("Новости", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
</tr>
<tr style="font-size:12px;font-weight:500;">
<td>@Html.ActionLink("О компании", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
<td>@Html.ActionLink("Возможности", "About", "Home")</td>
<td>@Html.ActionLink("Новости", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
</tr>
<tr style="font-size:12px;font-weight:500;">
<td>@Html.ActionLink("О компании", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
<td>@Html.ActionLink("Возможности", "About", "Home")</td>
<td>@Html.ActionLink("Новости", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
</tr>
<tr style="font-size:12px;font-weight:500;">
<td>@Html.ActionLink("О компании", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
<td>@Html.ActionLink("Возможности", "About", "Home")</td>
<td>@Html.ActionLink("Новости", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
</tr>
<tr style="font-size:12px;font-weight:500;">
<td>@Html.ActionLink("О компании", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
<td>@Html.ActionLink("Возможности", "About", "Home")</td>
<td>@Html.ActionLink("Новости", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
</tr>
<tr style="font-size:12px;font-weight:500;">
<td>@Html.ActionLink("О компании", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
<td>@Html.ActionLink("Возможности", "About", "Home")</td>
<td>@Html.ActionLink("Новости", "About", "Home")</td>
<td>@Html.ActionLink("О продукции", "About", "Home")</td>
</tr>
</table>
<div class="float-left">
<p>© @DateTime.Now.Year - ONM Web studio</p>
</div>
<div class="float-right">
<ul id="social">
<li><a href="http://facebook.com" class="facebook">Facebook</a></li>
<li><a href="http://twitter.com" class="twitter">Twitter</a></li>
</ul>
</div>
</div>
</footer>
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
</html>
index.cshtml的代码
@model IEnumerable<kazwaySite.Models.News>
<script type="text/javascript">
$(function () {
$("#accordion").accordion({ header: "h3" });
});
</script>
<div id="accordion">
<div>
<h3><a href="#">First</a></h3>
<div>Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.</div>
</div>
<div>
<h3><a href="#">Second</a></h3>
<div>Phasellus mattis tincidunt nibh.</div>
</div>
<div>
<h3><a href="#">Third</a></h3>
<div>Nam dui erat, auctor a, dignissim quis.</div>
</div>
</div>