Why does select box on mac chrome doesn't respond to click event? [duplicate]

Possible Duplicate:
JQuery function doesn't work on Chrome on Mac, but works on Chrome on Win 7 and all other browsers

I have a select - option list

<div class="social-option">
    <select name="hex_theme_options[social-service-1]">
        <option selected="selected" value="facebook">facebook</option>
        <option value="0"></option>
        <option value="twitter">twitter</option>
        <option value="linkedin">linkedin</option>
        <option value="e-mail">e-mail</option>
        <option value="phone">phone</option>
        <option value="instagram">instagram</option>
        <option value="flickr">flickr</option>
        <option value="dribbble">dribbble</option>
        <option value="skype">skype</option>
        <option value="picasa">picasa</option>
        <option value="google-plus">google-plus</option>
        <option value="forrst">forrst</option>
    </select>
</div>

why does this works on a PC but not on mac?

$('.social-option select').on('click', function () {
    alert('bla');
});

http://jsfiddle.net/4BBcZ/

UPDATE
I need to use on click event, not on change.

Answers:

Answer

Use the change event instead:

$('.social-option select').on('change', function () {
    alert('bla');
});

From the documentation:

The change event is sent to an element when its value changes. This event is limited to elements, boxes and elements. For select boxes, checkboxes, and radio buttons, the event is fired immediately when the user makes a selection with the mouse, but for the other element types the event is deferred until the element loses focus.

IIRC, the click event works for <option>s in Firefox, however does not work in Chrome. The best, most supported event is change.

To get the value of the option selected, simply use .val() as you would with any other input:

$('.social-option select').on('change', function () {
    alert($(this).val());
});
Answer

Instead of the "click" event, use "change", as in

 $(".social-option select").change(function(){
       alert('bla');    
    });

stackoverflow reference

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.