Print when textarea has overflow

前端 未结 11 950
眼角桃花
眼角桃花 2020-12-04 23:59

I have a form with some text areas that allow a scroll bar when the text exceeds the text box. The user would like to be able to print the screen, and this text is not visib

11条回答
  •  一整个雨季
    2020-12-05 00:23

    Loop through each of your text areas and move the content to a holder

        window.onbeforeprint = function () {
            $('.print-content').remove();
            $('textarea').each(function () {
                var text = $(this).val();
                $(this).after('');
            });
        }
    

    And use the following CSS

    .print-content {
      display: none !important;
    }
    
    @media print {
      .print-content {
        display: block !important;
      }
      textarea {display: none !important;}
    }
    

提交回复
热议问题