function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
arabisaysarabisays 

Hide Sidebar Search Options Using JavaScript(JQuery)

Hi,

I am trying to hide some of the Side Bar Search options(Usually it has all the Objects)  using JavaScript.

I have created a custome home page component and pasted the below code by clicking Edit HTML.

    $("#sen option[value='087']").remove();
    $("#sen option[value='a04']").remove();
    $("#sen option[value='a07']").remove();
    $("#sen option[value='a0B']").remove();
    $("#sen option[value='a0H']").remove();
    $("#sen option[value='a0I']").remove();
    $("#sen option[value='a0K']").remove();
    $("#sen option[value='a0L']").remove();

But I am not able to hide the components.
PS: I have pasted the HTML of the side bar search to JSFiddle and used the same script. It is working fine in JSFiddle.
Best Answer chosen by arabisays
arabisaysarabisays
I have solved it modifying the code:

function hideLinks() {
    $("#sen option[value='087']").remove();
    $("#sen option[value='a04']").remove();
    $("#sen option[value='a07']").remove();
    $("#sen option[value='a0B']").remove();
    $("#sen option[value='a0H']").remove();
    $("#sen option[value='a0I']").remove();
    $("#sen option[value='a0K']").remove();
    $("#sen option[value='a0L']").remove();
    $("#sen option[value='0Q0']").remove();
}
if (window.addEventListener) {
    window.addEventListener("load", hideLinks, false);
} else if (window.attachEvent) {
    window.attachEvent("onload", hideLinks);
}