I have an html select
element with an id
of background
designed to set a background image for the <div class=”results-area”>
. Then I have a print button to print the .results-area
content.
The problem is that when I wanna print the .results-area
I need to set what background image to set when printing, if I use CSS @media print
I cannot set rules which background it should print (based on user selection).
Is there another way to accomplish that?
HTML
<select id="background">
<option value="url(picture1.jpg)">picture1</option>
<option value="url(picture2.jpg)">picture2</option>
<option value="url(picture3.jpg)">picture3</option>
<option value="url(picture4.jpg)">picture4</option>
<option value="url(picture5.jpg)">picture5</option>
<option value="url(picture6.jpg)">picture6</option>
</select>
<div class=”results-area”>
...
</div>
<a id="printMe" class="btn btn-warning">Print</a>
jQuery
$('#background').change(function () {
$('.results-area').css("background-image", $(this).val());
})
$('#printMe').click(function () {
print()
});
CSS:
@media print {
.results-area{
background-image: ??????;
}
}