上次这个社区的成员问了一个类似的问题,我们的朋友 Igor 给出了正确的答案。
function addTextToInput(anElement) {
var text = document.getElementById('jaloby').value;
if (text != "")
text += ",";
text += anElement.innerText;
document.getElementById('jaloby').value = text;
}
<input id="jaloby" />
<input id="obekt" />
<input id="diagnoz" />
<br/>
<button type="button" onclick="addTextToInput(this)">1</button>
<button type="button" onclick="addTextToInput(this)">2</button>
<button type="button" onclick="addTextToInput(this)">3</button>
从上面的代码中,您可以看到按钮填充value了带有 ID 的字段jaloby。现在的任务是让他们同时填写所有三个字段。我如何告诉 js 填写我案例中的所有三个字段。我尝试了各种方法都没有帮助,因为不幸的是我不是 js 的朋友(
1 个回答