Search code examples
jqueryjquery-selectorshtml-select

select next option in jquery selectmenu


trying to create a button that will goto the next option in a selectmenu that has $selectmenu assigned to it.

$('option:selected', 'select').removeAttr('selected').next('option').attr('selected', 'selected');

works on a standard HTML select menu but not when it has the jquery $selectmenu assigned to it.

$('select#toolMenu').selectmenu({
    style:'popup', 
    width: 600,
    menuWidth: 600,
    maxHeight: 400,
    format: addressFormatting,
    change: function () { 
        var val = this.value;
        window.location=val;
    } 
});

Any idea how I can control the selectmenu?


Solution

  • as the menu was meant to load a new page for each option i just grabbed the original option val() and went to the next page where the menu would automatically re-initiate with the dom.

            jqueryMenu()
    
            $('a.previous').click(function(){
    
                val = $('option:selected', 'select').previous('option').val();
                window.location=val;
    
            })
    
            $('a.next').click(function(){
    
                val = $('option:selected', 'select').next('option').val();
                window.location=val;
    
            })