【发布时间】:2026-02-10 17:55:01
【问题描述】:
我正在使用setAttribue,如下所示。它只在第一次工作,之后变化的值显示alert,但没有设置document.getElementById("to").setAttribute("value", selValue);
document.getElementById("listcontact").onchange = function () {
var selIndex = document.getElementById("listcontact").selectedIndex;
var selValue = document.getElementById("listcontact").options[selIndex].innerHTML;
var contactVal = selValue.split(';');
var phone = contactVal[2];
alert(phone);
document.getElementById("to").setAttribute("value", selValue);
selIndex = "";
selValue = "";
phone = "";
selValue = "";
};
为什么这没有按我的预期工作,我该如何解决?
【问题讨论】:
标签: javascript html