HTML - 为什么我无法输入此HTML文本区域?

时间:2016-05-26 13:46:38

标签: javascript html css textarea

我有一个文字区域:

<textarea name="p_comments" rows="5" cols="39" align="left" wrap="cwrap" onfocus="this.blur()">

当我输入此框时,它什么也没做。它旁边有一个文本框可以使用,但它没有onfocus="this.blur()"这是罪魁祸首吗?

我试图在源代码编辑器中删除它,但是,我仍然无法输入框。我无法更改服务器上的HTML,所以我想看看“模糊”是原因还是css?

的CSS:

element.style {
}
textarea[Attributes Style] {
    text-align: left;
    white-space: pre-wrap;
    word-wrap: break-word;
}
textarea {
    padding: 2px 0px 0px 2px;
}
user agent stylesheet
input:not([type="image" i]), textarea {
    box-sizing: border-box;
}
textarea {
    font-family: monospace;
    border-color: rgb(169, 169, 169);
}
textarea {
    -webkit-appearance: textarea;
    background-color: white;
    border-image-source: initial;
    border-image-slice: initial;
    border-image-width: initial;
    border-image-outset: initial;
    border-image-repeat: initial;
    -webkit-rtl-ordering: logical;
    -webkit-user-select: text;
    flex-direction: column;
    resize: auto;
    cursor: auto;
    border-width: 1px;
    border-style: solid;
}
input, textarea, keygen, select, button {
    text-rendering: auto;
    color: initial;
    letter-spacing: normal;
    word-spacing: normal;
    text-transform: none;
    text-indent: 0px;
    text-shadow: none;
    display: inline-block;
    margin: 0em 0em 0em 0em;
    font: 13.3333px Arial;
}
input, textarea, keygen, select, button, meter, progress {
    -webkit-writing-mode: horizontal-tb;
}
Inherited from td
TD {
    font-family: "Arial";
    font-size: 10pt;
}
Inherited from table
table {
    white-space: normal;
    line-height: normal;
    font-weight: normal;
    font-size: medium;
    font-variant: normal;
    font-style: normal;
    color: -internal-quirk-inherit;
    text-align: start;
}
table {
    display: table;
    border-collapse: separate;
    border-spacing: 2px;
    border-color: grey;
}
Inherited from td
TD {
    font-family: "Arial";
    font-size: 10pt;
}
Inherited from table
table {
    white-space: normal;
    line-height: normal;
    font-weight: normal;
    font-size: medium;
    font-variant: normal;
    font-style: normal;
    color: -internal-quirk-inherit;
    text-align: start;
}
table {
    display: table;
    border-collapse: separate;
    border-spacing: 2px;
    border-color: grey;
}






4 个答案:

答案 0 :(得分:0)

onfocus="this.blur()"绝对是罪魁祸首。它试图使文本区域只读。

答案 1 :(得分:0)

删除onfocus =&#34; this.blur()&#34;来自textarea

答案 2 :(得分:0)

onfocus="this.blur()"

是的,这就是问题所在。如果你从devtool中删除它,它将不会改变任何东西,因为当你尝试时已经执行了JavaScript。

解决方案是删除这个事件监听器(我真的不知道你怎么知道你需要一个函数名 - 你还没有),或者使用JavaScript用其他textarea替换元素。 (虽然这样做有点难看)

答案 3 :(得分:0)

好的,您可以使用此脚本force重点关注textarea

var allEle = document.getElementsByTagName('textarea');
for(i=0; i<allEle.length; i++){
    var ele = allEle.item(i);
  focueEle(ele)
}

function focueEle(ele){
    ele.onfocus = function() {
        ele.focus();
    }
}

https://jsfiddle.net/b6pshw0m/2/

相关问题