Item highlight using jquery

2 posts, 0 answers
  1. Afroz khan
    Afroz khan avatar
    38 posts
    Member since:
    Dec 2009

    Posted 10 Aug 2014 Link to this post

    Hi Team,

    Can we apply jquery to get the checked item and apply the css?
    Can I do the same as I am doing for RoleName, means need to apply the jquery for radlistbox

    function SaveRolePermissions() {

    var roleName = $("#" + "<%=txtRoleName.ClientID %>");
    var permission = $find("<%=rdlistMenuPermission.ClientID %>");
    var validationMsg = headerMessage;

    var validationFlag = false;
    if (!jQuery.trim(roleName.val())) {
    roleName.css("background-color", colorCode);
    validationMsg = validationMsg + "Role is required \n";
    validationFlag = true;
    } else roleName.css("background-color", "");
    var item;
    var items;
    var i;
    if (permission._checkedIndices == "") {
    items = permission.get_items();
    for (i = 0; i <= items.get_count() - 1; i++) {
    item = items.getItem(i);
    item._element.style.backgroundColor = colorCode;
    }
    validationMsg = validationMsg + "Permission is required \n";
    validationFlag = true;

    } else {
    items = permission.get_items();
    for (i = 0 ; i <= items.get_count() - 1; i++) {
    item = items.getItem(i);
    item._element.style.backgroundColor = "";
    }
    }

    if ( validationFlag) {
    alert(validationMsg);
    return false;
    }
    return true;


    }
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Aug 2014 in reply to Afroz khan Link to this post

    Hi Afroz khan,

    Please try the below JQuery to change the background color of the checked item. Based on your requirement try to use the below code snippet.

    JavaScript:
    function pageLoad() {
        $(document).ready(function () {
            $('input[type=checkbox]').each(function () {
                var checkedItem = (this.checked ? $(this).next("span").css("background-color", "Red") : "");
            });
        });
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top