【问题标题】:HTML underline buttonHTML 下划线按钮
【发布时间】:2015-02-16 19:37:34
【问题描述】:

您好,我正在制作文字处理器,需要制作一个按钮来为文本区域中的文本添加下划线。我制作了一个按钮,使文本斜体,但在下划线按钮上不确定。任何帮助将不胜感激

<textarea rows="10" cols="100" id="myP" >
      Type text here...
</textarea>
      <br>
      <br>
<button type="button" onclick="myFunction()">Set font Italic</button>

<script>
function myFunction() {
document.getElementById("myP").style.fontStyle = "italic";
}
</script>

【问题讨论】:

    标签: javascript html css underline


    【解决方案1】:

    从样式对象更改textDecoration 属性,这反过来又会修改text-decoration CSS 样式:

    function underline_text(){
        document.getElementById("myP").style.textDecoration = "underline";
    }
    

    JSFiddle

    【讨论】:

      【解决方案2】:

      这里有一个解决方案:

      <button type="button" onclick="myFunction2()">underline</button>
      
      <script>
      function myFunction2() {
      document.getElementById("myP").style.textDecoration = "underline";
      }
      </script>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-03-13
        • 2015-10-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-14
        • 1970-01-01
        相关资源
        最近更新 更多