It's doing exactly what your code asks it to do, which is to toggle
the visibility of #divarea every time you click the dropdown. What you
want is

$('#dropdown').change(function(){
    $('#divarea')[ ($(this).val() == 'double') ? 'hide' : 'show' ]()
});

equivalent to

$('#dropdown').change(function(){
    if ($(this).val() == 'double')
        $('#divarea').hide();
    else
        $('#divarea').show();
});

cheers,
- ricardo

On Dec 23, 2:44 am, "Louie Miranda" <lmira...@gmail.com> wrote:
> I tried to hide the <div id="divarea"> using the toggle() function below.
>
> javascript code
>
> <script type="text/javascript">
>
> > $(document).ready(function() {
>
> >         $("#dropdown").click(function() {
> >         $("#divarea").toggle();
> >         });
>
> > });
> > </script>
>
> html code
>
>
>
>
>
> > <p>
> > <select id="dropdown" name="layout">
> > <option>None</option>
> > <option value="single">Single</option>
> > <option value="double">Double</option>
> > </select>
> > </p>
>
> > <br /><br />
>
> > <div id="divarea">Louie Miranda (web.LM), JQuery show/hide toggle
> > effect</div>
>
> Unfortunately, upon clicking the <select> drop down switch, it automatically
> hides it right away. How can I hide it, if it only selects the value
> "Double"?
>
> I have the actual demo 
> here:http://labs.louiemiranda.net/js/jquery_show_hide_toggle_dropdown.php
>
> Help!
> --
> Louie Miranda (lmira...@gmail.com)http://www.louiemiranda.net
>
> Security Is A Series Of Well-Defined Steps
> chmod -R 0 / ; and smile :)

Reply via email to