2009-02-24 15 views

Respuesta

44

No necesita un script preempaquetado para esto, solo un par de líneas de código.

// get your select element and listen for a change event on it 
$('#selectEl').change(function() { 
    // set the window's location property to the value of the option the user has selected 
    window.location = $(this).val(); 
}); 
8

No he probado esto, pero creo que es equivalente a la muestra en la página a la que se hace referencia.

$(document).ready(function() { 
    $('#select').change(function() { 
     location.href = $(this).val(); 
    }); 
}); 

<select id="select"> 
    <option value="#">Select a location</option> 
    <option value="location.htm">Location</option> 
    <option value="other.htm">Other</option> 
</select> 
+0

Me parece o me falta un ')'? De todos modos ... no es jQuery, pero para algo tan ad hoc es más fácil y simple usar un fragmento de código en línea.