0

I want to hide few buttons to print so I am using this CSS code but it is not working still button are showing in print HTML code is

.btn btn-primary * {
  visibility: hidden;
}
<div id="control" style="display: none">
  <button class="btn btn-primary" onclick="toEmail()">Send to Mail</button>&nbsp;<button onclick="window.print();" class="btn btn-warning">Send to PDF</button>
</div>
Ali Esmailpor
  • 1,209
  • 3
  • 11
  • 22
jugal
  • 341
  • 1
  • 3
  • 17

1 Answers1

1

Because these two classes are written in the same button tag. This means that the selector should look like this, and without *:

.btn.btn-primary {}

Since * is a reference to all children of the current element.

In this example, I removed display: none from id="control" to visually understand that the code works.

.btn.btn-primary {
    visibility: hidden;
}
<div id="control"><button class="btn btn-primary" onclick="toEmail()">Send to Mail</button>&nbsp;<button onclick="window.print();" class="btn btn-warning">Send to PDF</button></div>
s.kuznetsov
  • 14,870
  • 3
  • 10
  • 25