asp.net mvc - Why doesnt my jquery execute? -


I am trying to show and hide a div element with the jquery toggle method. I have a link button that calls JavaScript to the onclick page. When clicking on the link button, the page does a postback, when I announced the javascript function to return false. How did anyone know how to solve this?

  Function Toggle () {$ ('#Apps'). Toggle ("sharp"); } & Lt; / Script & gt; & Lt; Form runat = "server" & gt; & Lt; ASP: LinkButton ID = "LinkButton 1" Runat = "Server" OnClientClick = "Toggle (); Return Return;" Text = "show / hide" & gt; & Lt; / ASP: LinkButton & gt; & Lt; Div id = "app" style = "background-color: fusia, width: 900px; height: 300px;" & Gt; & Lt; P & gt; JQuery example & lt; / P & gt; & Lt; / Div & gt; & Lt; / Form & gt;  

Write your JS again on the following and it should work properly

& lt; Script type = "text / javascript" & gt; $ ('# & Lt;% = LinkButton1.ClientID%> & gt;') Click (function (e) {$ ('# app') toggle ("sharp"); e.preventDefault ();}); & Lt; / Script & gt; & Lt; Form runat = "server" & gt; & Lt; ASP: LinkButton ID = "LinkButton 1" Runat = "Server" Text = "Show / Hide" & gt; & Lt; / Asp: LinkButton & gt; & Lt; Div id = "app" style = "background-color: fusia, width: 900px; height: 300px;" & Gt; & Lt; P & gt; JQuery example & lt; / P & gt; & Lt; / Div & gt; & Lt; / Form & gt;

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -