Dropdown event on change

Jquery detect change on dropdown with repeated selection

HTML

<select>
    <option value="1">Test 1</option>
    <option value="2">Test 2</option>
    <option value="3">Test 3</option>
</select>
<div id="result"></div>

CSS

pre {
    line-height: 6px
}

JavaScript

$(function() {
    var lastFocusValue = '';
    var focusState = 0;

    var changeWithRepeats = function(newestValue) {
        // Your change action here
        $('#result').append('<pre>               changed to value: ' + newestValue + '   &lt;---- trigger</pre>');
    };

    $('select').click(function() {
        if (focusState == 1) {
            focusState = 2;
            return;
        } else if (focusState == 2) $(this).blur();
    }).focus(function(e) {
        focusState = 1;
        lastFocusValue = $(this).val();
        $('#result').append('<pre>               focus: ' + lastFocusValue + ' (last focus)</pre>');
    }).blur(function() {
        focusState = 0;
        $('#result').append('<pre>               blur: ' + lastFocusValue + ' (last focus)</pre>');
        if ($(this).val() == lastFocusValue) {
            // Same value kept in dropdown
            changeWithRepeats($(this).val());
        }
    }).change(function() {
        $('#result').append('<pre>               change: ' + $(this).val() + ' (new value)</pre>');
        changeWithRepeats($(this).val());
    });
});