title: Calling JavaScript function in MVC 5 Razor view
body: <p>I have seen in another post that you can call a JavaScript function in your razor code like so:</p>
  
  <pre><code>@:FunctionName()
  </code></pre>
  
  <p>For me though this only outputs the actual words <code>FunctionName()</code></p>
  
  <p>Here is my view:</p>
  
  <pre><code>@model PriceCompare.Models.QuoteModel
  
  @{
      ViewBag.Title = "Quote";
  }
  
  &lt;h2&gt;Quote&lt;/h2&gt;
  
  @if (@Model.clarify == true)
  {
      // do drop down loic
      @:ShowClarify();
  }
  else
  {
      // fill quote
      @:ShowQuote();
  }
  &lt;div class="clarify"&gt;
  
      You can see the clarify div
  &lt;/div&gt;
  &lt;div class="quote"&gt;
  
      You can see the quote div
  &lt;/div&gt;
  
  @section head {
  
      &lt;script type="text/javascript"&gt;
  
          $(document).ready(
              function ShowQuote() {
                  $(".quote").show();
              },
              function ShowClarify() {
                  $(".clarify").show();
              }
          );
  
      &lt;/script&gt;
  }
  </code></pre>
  
  <p>Is it because I have nested it in an `@if'?  Anyway around this?</p>