search

Home  >  Q&A  >  body text

Hide button after clicking window.print

I need to display: None after clicking the print button. But the print page is opened using the window.open command. So I tried inlining the CSS to print without showing it, but it doesn't work.

This is where I put the inline CSS

<input type="button" style="  @media print{ display: none; }"  id="printPageButton"   
 onclick="   window.print();   "    class="printPageButton noprint" value="Print" >

P粉762447363P粉762447363239 days ago351

reply all(1)I'll reply

  • P粉810050669

    P粉8100506692024-03-30 00:46:35

    Media queries do not exist in inline CSS. You can use CSS @media queries in external CSS files. For example:

    @media print {
      #printPageButton {
        display: none;
      }
    }

    Content to print

    reply
    0
  • Cancelreply