In my report, there is a details section below. The screen provides instructions to view the details with a button that toggles the list's visibility.
When printing the report, I only want the instructions to show if the list is visible. If the list is hidden, I want the instructions to remain hidden as it would be irrelevant on paper and could give the impression that something is missing.
I am unsure how to apply the media-print style within the toggleListVisibility() function. Is it possible to add a class like clsInstructions.addClass(media-print-display-none) or clsInstructions.removeClass(media-print-display-none)?
@media print {
.noprint, .noprint * {display: none !important;}
}
<p>...Main report summary...</p>
<p class='clsInstructions'>See list below for details and suggested actions.</p>
<button type='button' class='noprint' onclick='toggleListVisibility()'>Show / hide list</button>
<div id='myList' style='display:none;'>...details content here...</div>
function toggleListVisibility(){
$('#myList').toggle();
if ($('#myList').is(":visible")) {
//make the instructions visible to the printer...
} else {
//make the instructions display:none to the printer, but still visible on screen. how???...
}
}