I am trying to change the color of all the <li>
links on web app using jQuery, but don't know why it is not working?
I have my style statement at the top in my layout.cshtml page, and the jQuery function at the bottom.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - Contoso University</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
<style>
li {color: blue;}
.emphasis {color: indianred;}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Contoso University", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
@if (User.Identity.IsAuthenticated)
{
if (!User.IsInRole("Instructor"))
{
<li>@Html.ActionLink("Students", "Index", "Student")</li>
}
<li>@Html.ActionLink("Courses", "Index", "Course")</li>
<li>@Html.ActionLink("Instructors", "Index", "Instructor")</li>
if (!User.IsInRole("Student") && !User.IsInRole("Instructor"))
{
<li>@Html.ActionLink("Departments", "Index", "Department")</li>
}
if (!User.IsInRole("Student"))
{
<li>@Html.ActionLink("Enrollments", "Index", "Enrollment")</li>
}
}
</ul>
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - Contoso University</p>
</footer>
</div>
@*<script>
$('li').addClass('emphasis');
</script>*@
<script>
$(function () {
$('li').addClass('emphasis');
});
</script>
</body>
</html>
What is it that I am doing wrong?