Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>document.getElementById("file").children[1].style.display = "none"; </code></pre> <p>Is hiding the 'Save' menu item (the 2nd child of <code>&lt;ul id="file"&gt;</code>).</p> <pre><code>document.getElementById("edit").children[1].style.display = "none"; </code></pre> <p>Is hiding the 'Delete' menu item (the 2nd child of <code>&lt;ul id="edit"&gt;</code>).</p> <p>If you want to hide the 'Add New' submenu item, you should target the first child of <code>&lt;ul id="edit"&gt;</code> like this:</p> <pre><code>document.getElementById("edit").children[0].style.display = "none"; </code></pre> <p>If you want to hide the entire 'Edit' submenu with all items, you should target the <code>&lt;ul id="edit"&gt;</code> like this:</p> <pre><code>document.getElementById("edit").style.display = "none"; </code></pre> <p>This does point out an important drawback of using <code>children</code> as a means of selecting menu items. If the order of the items changes, so does your Javascript.</p> <p>You are much better off targeting the items by their <code>class</code>names or <code>id</code>s. If you remove the inner <code>div</code> from the <code>a</code> link in each item (this is superfluous), and replace the <code>id</code> on the <code>li</code> element, you can target just the menu item you want:</p> <pre><code> &lt;ul id="edit"&gt; &lt;li id="div_rssims_edit_addnew"&gt;&lt;a href="#nogo" onclick="rssims_addnew()"&gt;Add new&lt;/a&gt;&lt;/li&gt; &lt;li id="delete"&gt;&lt;a href="#nogo" onclick="sims_delete()"&gt;Delete&lt;/a&gt;&lt;/li&gt; &lt;li id="clear"&gt;&lt;a href="#nogo" onclick="sims_reset()"&gt;Clear Form&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; document.getElementById("div_rssims_edit_addnew").style.display = "none"; </code></pre> <p>This always works, no matter what the order of the items is. It still blows up with an error if the element(s) are not present in the page. To prevent this, you best use a javascript library like jQuery to do this: <a href="http://api.jquery.com/hide/" rel="nofollow">http://api.jquery.com/hide/</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload