Tuesday, March 18, 2014

How to change CSS on classname Click?

$(document).ready(function () {
    GetProduct(2); Getsafetymenu(1);
    $(".ln").on("click", function () {
        $(".ln").removeClass("on");
        $(this).addClass("on");
        $(".ln").css({ cursor: "pointer" });
        $(this).css({ cursor: "default" });
     
       
    });
    $(".mn").on("click", function () {
        $(".mn").removeClass("mn1");
        $(this).addClass("mn1");
        $(".mn").css({ cursor: "pointer" });
        $(this).css({ cursor: "default" });
     
    });
});
function GetProduct(SafetyCatId) {
    $.ajax({
        type: "POST",
        url: "SafetyEnviornment.aspx/Getsafetysheet",
        data: '{SafetyCatId: ' + SafetyCatId + '}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: OnSuccess,
        failure: function (response) {          
        },
        error: function (response) {          
        }
    });
    if (SafetyCatId = 2) {
        $('#lcat2').css({ cursor: "default" });
       $('#lcat2').addClass("on");

    }
}
function OnSuccess(response) {
    var xmlDoc = $.parseXML(response.d);
    var xml = $(xmlDoc);
    var customers = xml.find("tblSafetyEnvironment");  
    var sttable = '';
    var name = '';
    var des = '';
    $.each(customers, function () {
        var customer = $(this);
        var pagecaption = $(this).find("pagecaption").text();
        var PageName = $(this).find("PageName").text();
        name = $(this).find("SafetyCatname").text();
        des = $(this).find("SafetyCatDescription").text();
        sttable += '<li> <a href="Safety/' + pagecaption + '">' + PageName + '</a></li>';
    });
    $("#ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_lblSafetyCategoryDesc").html(des);
    $("#ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_lblSafetyCategoryName").html(name);
    $("#ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_rptsafetydatasheet").html(sttable);
};
function Getsafetymenu(SafetyId) {
    $.ajax({
        type: "POST",
        url: "SafetyEnviornment.aspx/Getsafetymenu",
        data: '{SafetyId: ' + SafetyId + '}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: OnSuccess1,
        failure: function (response) {},
        error: function (response) {}
    });
    if (SafetyId=1) { $('#b1').css({ cursor: "default" }); }
 
}

function OnSuccess1(response) {
    var sttable = response.d;
    $("#ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_spmenuDescription").html(sttable);
 
};

No comments:

Post a Comment