html之制作精美的多行文本框(包括js焦点事件)

版权声明:博客知识产权来源命运的信徒,切勿侵权 https://blog.csdn.net/qq_37591637/article/details/88419827

科普时间

1、对标签定义一个css样式:

document.getElementById("idname").style.display="none";

2、怎么设置textarea里面文本的间距

line-height: 1.5;


html页面

  <textarea id="mcontent" onfocus="setcolor(id)" onblur="savecolor(id)">
      </textarea>

css样式


#mcontent {
  margin-top: 6%;
  margin-left: 7%;
  width: 93%;
  font-size: 14px;
  height: 40%;
  line-height: 1.5;
}

  js代码

  function setcolor(id){
          document.getElementById(id).style.background="#208EDA";
          document.getElementById(id).style.color="white";
          document.getElementById(id).style.border="solid 1px #C92027";
        }

        function savecolor(id){
          document.getElementById(id).style.background="white";
              document.getElementById(id).style.color="black";
        }


最终效果如下

当失去焦点的时候

当获取焦点的时候

猜你喜欢

转载自blog.csdn.net/qq_37591637/article/details/88419827