I am trying to make some code shorter and usable. Can someone look over the code I wrote and let me know if it's done correctly? I think it is but it seems a little too simple. The code allows a user to select a location form a drop down, then goes to that page.
Old Code
if (typeof $.uniform === "undefined") {
} else {
$.uniform.update("select.jump");
$("select#mexico").change(function() {
window.location = $("select#mexico option:selected").val();
});
$("select#paris").change(function() {
window.location = $("select#paris option:selected").val();
});
$("select#london").change(function() {
window.location = $("select#london option:selected").val();
});
$("select#jumpMenu").change(function() {
window.location = $("select#jumpMenu option:selected").val();
});
}
New Code
if (typeof $.uniform === "undefined") {
} else {
$.uniform.update("select.jump");
$(this).change(function() {
window.location = $(this).val();
});
}
!=
and!==
in js \$\endgroup\$