Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't toggle a button on Index view of .net mvc 4 web application
    primarykey
    data
    text
    <p>I am trying to toggle a button on my .net mvc 4 application. I am using a Razor view engine. I wish to toggle a button and generate alternating images. If i click a button, it should generate a checked image, and if i click again, it should generate an unchecked image. I'm stuck on this since yesterday and am unable to make any progress. Could someone point out the mistake in this code. Below is my Index.cshtml file - </p> <pre><code>@using System.Web.Optimization &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;/head&gt; &lt;body data-spy="scroll" data-target=".bs-docs-sidebar"&gt; &lt;input type="image" src="/assets/ico/glyphicons_152_check.png" class="img-rounded" id="btn-true" /&gt; &lt;script type="text/javascript"&gt; $('#btn-true').bind("click", function () { if ($(this).prop("src", "/assets/ico/glyphicons_152_check.png")) { $(this).prop("src", "/assets/ico/glyphicons_153_unchecked.png"); } else if ($(this).prop("src", "/assets/ico/glyphicons_153_unchecked.png")) { $(this).prop("src", "/assets/ico/glyphicons_152_check.png"); } $(this).toggleClass("on"); }); &lt;/script&gt; &lt;!-- Le javascript ================================================== --&gt; &lt;!-- Placed at the end of the document so the pages load faster --&gt; &lt;script type="text/javascript" src="http://platform.twitter.com/widgets.js"&gt;&lt;/script&gt; @Scripts.Render("~/assets/js/jquery-1.9.1.js") @Scripts.Render("~/assets/js/bootstrap-transition.js") @Scripts.Render("~/assets/js/bootstrap-alert.js") @Scripts.Render("~/assets/js/bootstrap-modal.js") @Scripts.Render("~/assets/js/bootstrap-dropdown.js") @Scripts.Render("~/assets/js/bootstrap-tooltip.js") @Scripts.Render("~/assets/js/bootstrap-popover.js") @Scripts.Render("~/assets/js/bootstrap-button.js") @Scripts.Render("~/assets/js/bootstrap-typeahead.js") @Scripts.Render("~/assets/js/bootstrap-affix.js") @Scripts.Render("~/assets/js/holder/holder.js") @Scripts.Render("~/assets/js/google-code-prettify/prettify.js") @Scripts.Render("~/assets/js/application.js") &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload