Reputation: 181
hello i want to apply css for nav bar, i am retrivig nav bar values from database using Ajax.ActionLink, i tried javascript but i am getting error called
jQuery is not defined",
here is my code. and Test_Section is my Model.
<table style="width:auto">
@foreach (Test_Section p in Model)
{
<tr>
<td>
<div id="ajaxnav" class="navbar-left">
<ul class="nav nav-tabs nav-stacked">
<li>
@Ajax.ActionLink(p.SectionName, p.Title, new { id = p.StdSectionId , @class = "navigationLink"},
new AjaxOptions
{
UpdateTargetId = "getHtml",
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET"
}, new { style = "color:#428bca" , @class = "navigationLink" })
</li>
</ul>
</div>
</td>
</tr>
}
</table>
<script type="text/javascript">
$('.navigationLink').click(function () {
$('.navigationLink').removeClass('active');
$(this).addClass('active');
});
</script>
Please help me.
Upvotes: 0
Views: 758
Reputation: 4364
You need to use .click
inside
$(document).ready(function(){//...onclick(...)})
But first make sure, you include jquery script file in your html.
Upvotes: 0
Reputation: 1288
You need to include jQuery to your application by referencing it in your page, because the Error jQuery is not defined
or $ is not defined
occurs when jQuery is not (correctly) included in your page.
You should add this line before the <script>
section in your posted code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
Hope this help you.
Upvotes: 1