0

I have written a piece of jQuery that hides/shows a specified element when a drop down option/s is selected.

The problem I am having is that when one of the options is selected the page scrolls so that the bottom of the browser aligns with the top of the content that has just been hidden/shown. How do I stop this happening?

Below is a summarised version of the code.

$(function() {
    $('#billing_address2').change(function() {
        $('.calendar').hide();
        if ($(this).val() == "None") {
            $('.empty').show();
        }
        if ($(this).val() == "Arch Hill" || $(this).val() == "Balmoral" || $(this).val() == "Central Business District" || $(this).val() == "Eden Terrace" || $(this).val() == "Ellerslie" || $(this).val() == "Epsom") {
            $('.central').show();
        }
        if ($(this).val() == "Albany" || $(this).val() == "Bayswater" || $(this).val() == "Bayview" || $(this).val() == "Belmont") {
            $('.north').show();
        }
        if ($(this).val() == "Glendowie" || $(this).val() == "Kohimarama" || $(this).val() == "Meadowbank" || $(this).val() == "Mission Bay") {
            $('.east').show();
        }
        if ($(this).val() == "Avondale" || $(this).val() == "Blockhouse Bay" || $(this).val() == "Glen Eden" || $(this).val() == "Glendene") {
            $('.west').show();
        }
    ;});
});

<select id="billing_address2">
    <option selected value="None">Suburb...</option>
    <option value="Albany">Albany</option>
    <option value="Arch Hill">Arch Hill</option>
    <option value="Avondale">Avondale</option>
    <option value="Balmoral">Balmoral</option>
    <option value="Bayswater">Bayswater</option>
    <option value="Bayview">Bayview</option>
    <option value="Belmont">Belmont</option>
    <option value="Blockhouse Bay">Blockhouse Bay</option>
    <option value="Central Business District">Central Business District</option>
    <option value="Eden Terrace">Eden Terrace</option>
    <option value="Ellerslie">Ellerslie</option>
    <option value="Epsom">Epsom</option>
    <option value="Glen Eden">Glen Eden</option>
    <option value="Glendene">Glendene</option>
    <option value="Glendowie">Glendowie</option>
    <option value="Kohimarama">Kohimarama</option>
    <option value="Meadowbank">Meadowbank</option>
    <option value="Mission Bay">Mission Bay</option>
</select>
4

0 回答 0