bug of 'clear text form' script
bug of 'clear text form' script
我使用小脚本来清除文本形式的内容。它看起来很整洁,但是有一个bug。
如果我开始写,只是在表单的某个地方点击所有的内容被删除。
有什么办法解决这个问题吗??
要查看实际操作,请访问:
http://www.sandrophoto.com/2011/11/28/five-photography-tips-from-celebrated-pros/评论
开始写东西,而不是只是点击内部表单。看到了吗?文本被删除,这不是我需要的行为。
代码:<textarea tabindex="4" rows="10" cols="100%" id="comment" name="comment"
onclick="this.value='';" onfocus="this.select()"
onblur="this.value=!this.value?'Write your comment':this.value;">
Write your comment</textarea>
是否有办法使这个明确的文本行动只发生一次默认文本?然后保持静止?
如果要清除包含默认文本的this.value
,则将其设为条件。
我很抱歉我不能提供一个代码示例。我对html没有足够的信心,以确保我没有误导你。
在textarea中有三种情况:
- onclick:清除文本区域
- onfocus:选择此文本区域
- onblur:如果为空白,则用
Write your comment
代替
需要编辑的是action 1。(onclick)因为无论当前值是什么,每次用户单击时它都会清除它。仅当内容为默认设置(例如:Write your comment
)时需要清除。
- 应该是:onclick:如果值是
Write your Comment
则清除,否则什么都不做。
<textarea tabindex="4" rows="10" cols="100%" id="comment" name="comment"
onclick="if (this.value=='Write your comment'){this.value='';}"
onfocus="this.select()"
onblur="this.value=!this.value?'Write your comment':this.value;">
Write your comment</textarea>
相关文章:
- Dojo:访问dijit.form.Select中单击的项目
- Javascript form innerHTML
- html文件中的script标记根本不起作用
- 无法在有条件呈现的富:面板上提交h:form
- 用javascript将script元素附加到头部;铬不能工作
- Javascript form.submit()方法是如何工作的
- script标记如何解析node_modules的路径
- 通过jQueryAjax一起发布Array和Form数据时出现问题
- This.Form.Submit() on CakePHP
- 带有Request.Form的JScript数组
- 在<script src=“"></脚本>标签
- Google Script HtmlService,通过多个选项卡复制URL变量
- jQuery函数无法处理Form Submit
- 使用application/x-www-form-urlencoded使用node.js在post请求中发送数组
- 为什么firefox开发人员控制台引用script.js
- Javascript:获取“;FORM”;它是在.html到外部.js文件中创建的
- 如何停止向上滚动<按钮dojoType=“;dijit.form.Button”;type=“;提交”/>在
- 等效于<script src=“;something1.json”></脚本>
- Java Script: onsubmit=“check_rfields();” in form tag of html
- bug of 'clear text form' script