Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html onClick输入文本只读表单使用内联_Html_Events_Dom - Fatal编程技术网

Html onClick输入文本只读表单使用内联

Html onClick输入文本只读表单使用内联,html,events,dom,Html,Events,Dom,我对onclick输入表单有问题,它是只读的,但可以内联使用。 我只能做onclick is disable示例: <input type="text" onClick=this.disabled=true /> 这是一个可行的方法,但我需要的是,当onClick事件为只读时,我尝试以下方法: <input type="text" onClick=this.readonly=true /> 但它仍然不起作用。这已经得到了回答 onclick=document.getE

我对onclick输入表单有问题,它是只读的,但可以内联使用。 我只能做onclick is disable示例:

<input type="text" onClick=this.disabled=true />
这是一个可行的方法,但我需要的是,当onClick事件为只读时,我尝试以下方法:

<input type="text" onClick=this.readonly=true />
但它仍然不起作用。

这已经得到了回答

onclick=document.getElementById'Tbox'。readOnly=true


和之间有一点区别

readOnly:readOnly属性设置或返回文本字段是否为只读

将readonly更改为readonly,它将正常工作

<input type="text" onClick='this.readOnly = true;' value='checkMe'/>

请在单击文本框时双引号输入属性值。在单击文本框时,将其设置为只读没有任何意义。