This is a migrated thread and some comments may be shown as answers.

Item highlight using jquery

1 Answer 20 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Afroz khan
Top achievements
Rank 1
Afroz khan asked on 10 Aug 2014, 02:55 PM
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;


}

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 11 Aug 2014, 08:04 AM
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.
Tags
ListBox
Asked by
Afroz khan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or