Skip to main content

I'm trying to remove an item (Fruitsvalue=155 /Value=155 'Fruits')from from a select box drop down.

 <div class="control select"><selectselect">  <select id="product_cat"  name="product_cat[]"  class="category-select2 select2-hidden-accessible"  style=""  data-parsley-maxcheck="3"  multiple=""  data-parsley-multiple="product_cat[]"  tabindex="-1"  aria-hidden="true">hidden="true"  > <option class="level-0" value="115">Misc</option>   <option class="level-0" value="161">Vegetables</option>   <option class="level-0" value="160">Grains</option>   <option class="level-0" value="155">Fruits</option>   <option class="level-1" value="156">&nbsp;&nbsp;&nbsp;Apples</option>   <option class="level-1" value="157">&nbsp;&nbsp;&nbsp;Bananas<value="157">&nbsp;&nbsp;&nbspBananas</option> 

I'm using Wordpress and after many different attempts I haven't been able to remove it from the dropdown. For instanceFor example, I've tried the following JS code in my function.phpfunction.php file:

 function customcats_hook_javascript() {   ?>   <script>  var select = document.getElementById('product_cat')  select.removeChild(select.querySelector('option[value="155"]'))   </script>   <?php  }  add_action('wp_head', 'customcats_hook_javascript'); 

I'm trying to remove an item (Fruits/Value=155)from a select box drop down.

<div class="control select"><select id="product_cat" name="product_cat[]" class="category-select2 select2-hidden-accessible" style="" data-parsley-maxcheck="3" multiple="" data-parsley-multiple="product_cat[]" tabindex="-1" aria-hidden="true"> <option class="level-0" value="115">Misc</option> <option class="level-0" value="161">Vegetables</option> <option class="level-0" value="160">Grains</option> <option class="level-0" value="155">Fruits</option> <option class="level-1" value="156">&nbsp;&nbsp;&nbsp;Apples</option> <option class="level-1" value="157">&nbsp;&nbsp;&nbsp;Bananas</option> 

I'm using Wordpress and after many different attempts I haven't been able to remove it from the dropdown. For instance, I've tried the following JS code in my function.php file:

function customcats_hook_javascript() { ?> <script> var select = document.getElementById('product_cat') select.removeChild(select.querySelector('option[value="155"]')) </script> <?php } add_action('wp_head', 'customcats_hook_javascript'); 

I'm trying to remove an item (value=155 / 'Fruits') from a select box drop down.

 <div class="control select">  <select id="product_cat"  name="product_cat[]"  class="category-select2 select2-hidden-accessible"  style=""  data-parsley-maxcheck="3"  multiple=""  data-parsley-multiple="product_cat[]"  tabindex="-1"  aria-hidden="true"  > <option class="level-0" value="115">Misc</option>   <option class="level-0" value="161">Vegetables</option>   <option class="level-0" value="160">Grains</option>   <option class="level-0" value="155">Fruits</option>   <option class="level-1" value="156">&nbsp;&nbsp;&nbsp;Apples</option>   <option class="level-1" value="157">&nbsp;&nbsp;&nbspBananas</option> 

I'm using Wordpress and after many attempts I haven't been able to remove it from the dropdown. For example, I've tried the following JS code in my function.php file:

 function customcats_hook_javascript() {   ?>   <script>  var select = document.getElementById('product_cat')  select.removeChild(select.querySelector('option[value="155"]'))   </script>   <?php  }  add_action('wp_head', 'customcats_hook_javascript'); 
Source Link

Remove Item from Select Box

I'm trying to remove an item (Fruits/Value=155)from a select box drop down.

<div class="control select"><select id="product_cat" name="product_cat[]" class="category-select2 select2-hidden-accessible" style="" data-parsley-maxcheck="3" multiple="" data-parsley-multiple="product_cat[]" tabindex="-1" aria-hidden="true"> <option class="level-0" value="115">Misc</option> <option class="level-0" value="161">Vegetables</option> <option class="level-0" value="160">Grains</option> <option class="level-0" value="155">Fruits</option> <option class="level-1" value="156">&nbsp;&nbsp;&nbsp;Apples</option> <option class="level-1" value="157">&nbsp;&nbsp;&nbsp;Bananas</option> 

I'm using Wordpress and after many different attempts I haven't been able to remove it from the dropdown. For instance, I've tried the following JS code in my function.php file:

function customcats_hook_javascript() { ?> <script> var select = document.getElementById('product_cat') select.removeChild(select.querySelector('option[value="155"]')) </script> <?php } add_action('wp_head', 'customcats_hook_javascript');