Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript solution for hiding dropdown list options
    primarykey
    data
    text
    <p>Edit: Thanks everybody, but nothing seems to work. I am inserting this code in a file that I know is being used and that contains other javascript blocks normally formatted, and this still doesn't work. It works in a fiddle, but not on my code. I guess this is too specific to the platform and extension that I'm trying to modify (this is part of a Magento checkout step modified by a third party extension). I will start looking into replacing the list with a manually generated one. Thanks again.</p> <hr> <p>I am trying to hide an option in a dropdown list that is dinamically generated. The CSS solution doesn't work on all browsers, and even though I have found several similar questions here, neither one offers a solution that works for me.</p> <p>Here's what my list renders like:</p> <pre><code>&lt;select id="timeselect" name="adj[delivery_time][]" title="El plazo de la entrega" class="adjtimeselect select" type="time" &gt;&lt;option id="option-10" value="10" &gt;10&lt;/option&gt; &lt;option id="option-11" value="11" &gt;11&lt;/option&gt; &lt;option id="option-12" value="12" &gt;12&lt;/option&gt; &lt;option id="option-13" value="13" &gt;13&lt;/option&gt; &lt;option id="option-14" value="14" &gt;14&lt;/option&gt; &lt;option id="option-15" value="15" &gt;15&lt;/option&gt; &lt;option id="option-16" value="16" &gt;16&lt;/option&gt; &lt;option id="option-17" value="17" &gt;17&lt;/option&gt; &lt;option id="option-18" value="18" &gt;18&lt;/option&gt; &lt;option id="option-19" value="19" &gt;19&lt;/option&gt; &lt;option id="option-20" value="20" &gt;20&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I need to hide the option with value "12" for example. I am using this JS:</p> <pre><code>$("#timeselect option[value='12']").remove(); </code></pre> <p>Any advice would be greatly appreciated since I'm new to JS.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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