我有點困惑,我想了解window.location的原因。如果我創建一個鏈接,我不需要這個,但是如果我在選擇菜單中將值設置爲url,我需要使用它,爲什麼?是否因爲錨標籤自動執行此操作,並且由於選擇菜單不是爲導航而設計的,因此它們缺少構建功能?或者還有其他原因?爲什麼選擇菜單需要window.location?
var $select=$('<select></select>');
var $option=$('<option></option>');
var url= 'some url';
$option.val(url);
var button=$('<button></button>');
button.click(fucntion(){
window.location=$select.val();
});