jQuery select change/click problem - change doesn't work in IE, click doesn't work in Chrome

Posted by dan727 on Stack Overflow See other posts from Stack Overflow or by dan727
Published on 2010-04-20T21:26:13Z Indexed on 2010/04/20 21:43 UTC
Read the original article Hit count: 713

As the title says, I have a problem with binding to a change in a dropdown select list - it seems that "change" doesn't work with IE(7 or 8), so when I try the alternative and use a "click" event, it works in IE but doesn't work in Chrome! Am I missing something obvious here?

Here's my code:

//event handler for showing hidden form elements (also ensures only relevant hidden els shown)
        //IE needs click event instead of change
        $('.select_change').live("change", function(){
            //check if value is other
            if ($(this).val() == 'other') 
                $(this).parent().find(".hidden").show();
            //if user changes select value from other then hide input
            if ($(this).val() != 'other') 
                $(this).parent().find(".hidden").hide();
            return false;
        });

The dropdown HTML is as follows:

<select id="title" name="title" class="validate[required,funcCall[validateNotDefault]] select_change" >
<option value="default" selected="selected">Please choose from options</option>
<option value="yellow">Yellow</option>
<option value="black">Black</option>
<option value="chocoloate">Chocolate</option>

<option value="other">Other</option>
</select>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about web-development