Tag: 金字塔

在window.location重定向之后预先选择html选择选项

我有问题,在重定向页面后,我希望select在页面被重定向后将先前选择的选项作为选择的选项。 我在我的选择中有一个onchange ,它将根据用户的选择重定向用户(基本上刷新页面),但是在页面刷新后,所选选项将被重置并且列表中的第一个选项被选中。 $(“#reportTypes”).change(function () { var reportTypeID = $(this).val(); var deviceTypeID = $(‘#hDeviceTypeID’).val(); window.location.href = “http://127.0.0.1:6543/new_device/” + deviceTypeID + “/” + reportTypeID; $(‘#reportTypes’).val(reportTypeID);//tried to select the previous option but this doesn’t seem to work }); 如何在我的select显示所选选项而不在页面加载后重置?