Tuesday, May 27, 2014

What is Jquery

1) jQuery is a lightweight, "write less, do more", JavaScript library.

2) The jQuery library contains the following features:
  • HTML/DOM manipulation
  • CSS manipulation
  • HTML event methods
  • Effects and animations
  • AJAX
  • Utilities

hide functionality in jquery

1) Script

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
</script>


2) <p>ClickTo Hide!</p>

Javascript Confirmation box

 var answer = confirm('Are you sure you want to delete this?');
        if (answer) {
            console.log('yes');
        }
        else {
            console.log('cancel');
        }

Can user enter values in javascript alert?

var person=prompt("Please enter your name","Harry Potter");

if (person!=null)
  {
  x="Hello " + person + "! How are you today?";
  document.getElementById("demo").innerHTML=x;
  }

Monday, May 26, 2014

jquery textbox,label, a tag hide and show with ID

1) <script type="text/javascript" language="javascript">
        function changepassword() {
            var txtPassword = $("[id*=txtpassword]");
            txtPassword.show();
            var lblpassword = $("[id*=lblpassword]");
            lblpassword.hide();
            var idchangepassword = $("[id*=idchangepassword]");
            idchangepassword.hide();
            var idcancel = $("[id*=idcancel]");
            idcancel.show();
            var idsave = $("[id*=idsave]");
            idsave.show();
        }
        function cancelpassword() {
            var txtPassword = $("[id*=txtpassword]");
            txtPassword.hide();
            var lblpassword = $("[id*=lblpassword]");
            lblpassword.show();
            var idchangepassword = $("[id*=idchangepassword]");
            idchangepassword.show();
            var idcancel = $("[id*=idcancel]");
            idcancel.hide();
            var idsave = $("[id*=idsave]");
            idsave.hide();
        }
        function savepassword() {
            var txtPassword = $("[id*=txtpassword]");
            alert(txtPassword.val());
        }
    </script>

2)    <asp:Label ID="lblpassword" runat="server" Text="Shekhar123"></asp:Label>
                    <input id="txtpassword" type="text" style="display: none;" />
                    <a id="idchangepassword" href="javascript:changepassword();" style="text-decoration: none;
                        color: #15c;">Change Password</a> <a id="idsave" href="javascript:savepassword();"
                            style="display: none; text-decoration: none; color: #15c;">Save </a><a id="idcancel"
                                href="javascript:cancelpassword();" style="display: none; text-decoration: none;
                                color: #15c;">Cancel</a>

textbox show using jquery

1) <asp:Label ID="lblpassword" runat="server" Text="Shekhar123"></asp:Label>
                    <input id="txtpassword" type="text" style="display: none;">
                    <a id="changepassword" href="javascript:hi();">Change Password</a>

2) <script type="text/javascript" language="javascript">
        function hi() {
            var txtPassword = $("[id*=txtpassword]");
            txtPassword.show();
        }
    </script>

assign value to session varibale in javascript

  <%Session["Plan"] = "Holistic"; %>