I have a requirement where I need to add a border around objects when clicked, and remove the border when clicked again. Despite using an if condition with .css, I couldn't make it work as expected. When I tried to print the border width using alert function, it always returns empty. What could be causing this issue? Everything else seems to be functioning correctly.
$('a[id*="grd_WallPosts_lbtn_LikeDislike_Like"]').click(function () {
if ($(this).children('#imgLikeDislike_Like').css("border-width") == "1px") {
$(this).children('#imgLikeDislike_Like').css("border-width", "0px");
} else {
$(this).children('#imgLikeDislike_Like').css("border-width", "1px");
$(this).children('#imgLikeDislike_Like').css("border-style", "solid");
$(this).children('#imgLikeDislike_Like').css("border-color", "#b9b9b9");
var a = $(this).attr("id");
a = a.replace("grd_WallPosts_lbtn_LikeDislike_Like_", "");
$('#grd_WallPosts_lbtn_LikeDislike_Dislike_' + a).children('#imgLikeDislike_Dislike').css("border-width", "0px");
}
});