show more/Less text with just HTML and JavaScript

前端 未结 8 2126
心在旅途
心在旅途 2020-12-10 04:45

I am needing to create a show more/less text function, but with just JavaScript and HTML.. I can\'t use any additional libraries such as jQuery and it can\'t be done with CS

8条回答
  •  感动是毒
    2020-12-10 05:17

    Try to toggle height.

    function toggleTextArea()
    {
      var limitedHeight = '40px';
      var targetEle = document.getElementById("textarea");
      targetEle.style.height = (targetEle.style.height === '') ? limitedHeight : '';
    }
    

提交回复
热议问题