javascript - Diasble DiV on form load and enable the DIV on buttonClick using Jquery -


i have form in mvc, has button visible , div tag supposed not visible on form load.

on click of button, want make content of div tag visible. here, code>>

    <form id="displaycomment" onload="hidetextbox()" >          <label> comment </label> <input type="button" id="submit" name="submit" value="add comment" onclick="opentextbox();"/>          <div id="managetextbox" >             <input type="text" id="commentbox"  name="entercomment" value="" /><br />             <input type="button" id="addcomment" name="addcomment" value="submit"/>             <input type="button" id="cancelcomment" name="cancelcomment" value="cancel"/>         </div>    </form> 

i have 2 jquery , disable div tag on form load , on button click enable it. here script>>

 <script type="text/javascript">             function hidetextbox() {                 $("managetextbox").prop("disabled", true);             }          </script>          <script type="text/javascript">             function opentextbox() {                 $("#managetextbox").prop("disabled", false);             }         </script> 

but not firing expected. onload of form not fire. div tag visible on page load. me fix this.

you missing id selector $("managetextbox").prop("disabled", true);

try hide() , show()

you can use click events of submit that

    $(document).ready(function () {         $("#managetextbox").hide();      $("#submit").click(function () {         $("#managetextbox").show();     });     }); 

html

<form id="displaycomment">  <label> comment </label> <input type="button" id="submit" name="submit" value="add comment"/>  <div id="managetextbox" >     <input type="text" id="commentbox"  name="entercomment" value="" /><br />     <input type="button" id="addcomment" name="addcomment" value="submit"/>     <input type="button" id="cancelcomment" name="cancelcomment" value="cancel"/> </div> 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -