<textarea onfocus=" javascript:clearContents(this); this.cleared=true;" rows="5" cols="40" id="comment" name="comment" <?php if($vis["username"] == $pusername) { echo "DISABLED"; } ?>>...</textarea>
<input onsubmit="if (!this.comment.cleared) clearContents(this.comment); return true;" type="submit" name="Submit" value="Stem!"/>
function clearContents(element) {
element.innerHTML = '';
}
这行不通,我不知道为什么。它的作用:如果内容没有被关注/点击,则清除内容
最佳答案
clearContents( document.getElementById('comment') )
您应该绑定(bind) onsubmit
到 <form>
并且不引人注意地做到这一点,理想情况下......
关于Javascript onsubmit clearcontent 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3034050/