0

I created menu using fg.menu.js once its loaded I want to remove the unwanted menu for which user dont have access. for eg:-

<ul>
    <li> <a href="#">menu1</a>
        <ul>
            <li id="8000610"><a href="javascript: void(0)" onclick="javascript:setMenuItem('someaction')">Test1</a>
            </li>
            <li id="20247"><a href="javascript: void(0)" onclick="javascript:setMenuItem('someaction2')">Test2</a>
            </li>
            <li id="8000526"><a href="javascript: void(0)" onclick="javascript:setMenuItem('someaction3')">Test3</a>
            </li>
        </ul>
    </li>
</ul>

Now after loading the menu I want to remove the Test2

Thanks in advance

Henrik Andersson
  • 45,354
  • 16
  • 98
  • 92

1 Answers1

1

If you use jQuery, it's as simple as $('#20247').remove();

With vanilla JS it's

element = document.getElementById("element-id");
element.parentNode.removeChild(element);

Also, use search.

Community
  • 1
  • 1
Maxim Kumpan
  • 2,545
  • 2
  • 19
  • 23
  • Thanks $('#20247').remove() works just for info is this remove the element completely or just hide it? What if we need to bring it back. – user2408306 May 22 '13 at 09:12
  • It removes the element completely. Use .hide() to hide, .show() to show and .toggle() to toggle. All of these basic functions can be found in the jQuery api documentation here: http://api.jquery.com/ – Maxim Kumpan May 22 '13 at 09:39