[javascript] 자바스크립트를 사용하여 프린트 시에 특정 요소의 투명도를 변경하는 방법
// 특정 요소 선택
const element = document.querySelector('#yourElementId');

// 프린트 스타일 추가
const printStyle = document.createElement('style');
printStyle.textContent = '@media print { #yourElementId { opacity: 0.5; } }';
document.head.appendChild(printStyle);

// 프린트 이벤트 감지
window.onbeforeprint = () => {
  element.style.opacity = '0.5'; // 투명도 조절
};

window.onafterprint = () => {
  element.style.opacity = '1'; // 원래대로 복원
};

위의 코드는 요소의 투명도를 프린트할 때 조절하고 다시 복원하는 방법을 보여줍니다.

참고 문헌: