I'm trying to understand some of the fundamentals of javascript and DOM manipulation, and I've run into major roadblock. I'm trying a simple change of style to hide and show. It will work, but ONLY when I put in a breakpoint and run the code step by step. With no breakpoints in chrome developer tools it won't work. I wrote an equivalent in jQuery to, and ran into the exact same problem. Here is javascript:
(function topping() {
  var x = document.getElementById('pizza').value;
  var y = document.getElementById('pizza');
  y.addEventListener('change', changeToppings);
  function changeToppings() {
    if (x == 'Sicilian') {
      document.getElementById('RegToppings').style.display = 'none';
      document.getElementById('SicToppings').style.display = 'block';
    } else if (x == 'Regular') {
      document.getElementById('SicToppings').style.display = 'none';
      document.getElementById('RegToppings').style.display = 'block';
    }
  }
})();#SicToppings {
  display: none;
}
#RegToppings {
  display: block;
}<content>
  <select id="pizza">
    <option id="Regular">Regular</option>
    <option id="Sicilian">Sicilian</option>
  </select>
  <br />
  <input type="checkbox" id="buddybox" />buddy
  <select size="5" id="SicToppings">
    <option>mushrooms</option>
    <option>pepperoni</option>
  </select>
  <select size="5" id="RegToppings">
    <option>olives</option>
    <option>pasta</option>
  </select>
</content>and here's the jQuery:
$(document).ready(function() { $("#pizza").change(function () {
    var x = $("#pizza").value;
    if (x == "Sicilian")
    {
        $("#RegToppings").delay(1000).hide();
        $("#SicToppings").delay(1000).show();
    }
    else if (x == "Regular")
    {
        $("#SicToppings").delay(1000).hide();
        $("#RegToppings").delay(1000).show();
    }
    })
})
Thank you so much for any assistance you can offer. I'm not just looking for the solution, I'm trying to figure out why this is even happening, I think it has something to do with timing or call backs and I know that this a major component of javascript I have to understand. Thank you.
 
     
    