我正在编写代码来清除特定的输入字段,但按钮似乎只清除了一次。
<div class="input-field col s10">
<i class="material-icons prefix">web</i>
<input type="text" disabled name="pages-input" id="pages-input"></input>
</div>
<div class="col s2">
<input type="button" class="waves-effect waves-light btn red white-text" onClick="document.getElementById('pages-input').setAttribute('value', '');" value="Clear" />
</div>
答案 0 :(得分:-1)
输入是自动关闭的,您必须以不同方式设置值。
<div class="input-field col s10">
<i class="material-icons prefix">web</i>
<input type="text" disabled name="pages-input" id="pages-input" />
</div>
<div class="col s2">
<input type="button" class="waves-effect waves-light btn red white-text"
onClick="document.getElementById('pages-input').value = '';" value="Clear" />
</div>