I have a working jQuery codes that have a condition to return true if it matches the name.
jQuery(function(j) {
var strings = j(".user-nicename").text();
if (strings === "name1" ) {
j('.mention-name').hide();
j('.separator').hide();
j('.separator').hide();
j('.field_8263').css("display", "none");
j('#activity-personal-li').css("display", "none");
j('#groups-personal-li').css("display", "none");
}
});
jQuery(function(j) {
var strings = j(".user-nicename").text();
if (strings === "name2" ) {
j('.mention-name').hide();
j('.separator').hide();
j('.separator').hide();
j('.field_8263').css("display", "none");
j('#activity-personal-li').css("display", "none");
j('#groups-personal-li').css("display", "none");
}
});
However, I would like to add these names in an array. But once I do that, the code is not working anymore...
jQuery(function($) {
var strings = $(".user-nicename").text();
var authorName = ["name1" , "name2"];
if (strings === "authorName" ) {
$('.mention-name').hide();
$('.separator').hide();
$('.separator').hide();
$('.field_8263').css("display", "none");
$('#activity-personal-li').css("display", "none");
$('#groups-personal-li').css("display", "none");
}
});
Maybe anyone can help me? I think the "array" code is not correct. Thank you!