Tuesday 30 April 2013

JQUERY TIPS

       
     
      As a follower of JQuery, I would like to share some of the Jquery tips which I use in day to day coding. Hope you find it useful.


      1.      To hide or show an element.

 $("#EmailTextBox").hide();
    $("#NameLabel").show();

      2.      To set an alternative background color of a HTML table.

 $("#Table tbody tr:even").css("background-color", "#F7F7F7");
     $("#Table tbody tr:odd").css("background-color", "#F0F0F0");


      3.      To disable or enable an element.

$("#DropDownList").attr("disabled", "disabled");
$("#DropDownList").removeAttr("disabled");


      4.      To check the SelectedIndex of a dropdownlist

var selectedIndex = $("DropDownList").prop("selectedIndex");
    if (selectedIndex == 1) {
        //Write code
    }