0

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.

Dhia
  • 10,119
  • 11
  • 58
  • 69
Hemanthkumar Naik
  • 151
  • 1
  • 3
  • 11

2 Answers2

1

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.

Filnor
  • 1,290
  • 2
  • 23
  • 28
  • hello Chade, i added – Hemanthkumar Naik Aug 19 '16 at 05:03
  • Which Operating System and Browser (please with Version) are you using? Have you tried using other Browsers? By the way: it's `window` instead of `windows`. – Filnor Aug 19 '16 at 07:03
  • i am using windows7 64 bit, and using Google Chrome as my Browser – Hemanthkumar Naik Aug 19 '16 at 08:18
0

You need to use .click inside

  $(document).ready(function(){//...onclick(...)})

But first make sure, you include jquery script file in your html.

user786
  • 3,902
  • 4
  • 40
  • 72