lundi 23 juillet 2018

jquery if statement with print styles returns undefined?

I'm working on a project that makes use of a print stylesheet. I need to manipulate the DOM when a user prints the page to change the layout. (unfortunately cannot be done via aforementioned stylesheet).

After some research, I figured it would be acceptable to have jquery check if the navigation was hidden, (we have it set to display: none; when print styles are active) then include the DOM manipulation needed (the font-size: 100px was just a visual check to see if it works):

if ($('#topnav').is(':hidden')) { const headTwo = $('section div.tab-wrapper ul.nav.nav-tabs li a'); headTwo.css('font-size', '100px'); }

However, when run it returns "undefined." I threw an else in there to test if the

const headTwo = $('section div.tab-wrapper ul.nav.nav-tabs li a'); headTwo.css('font-size', '100px');

was the problem, but it works as intended. Is there any reason that the print style for #topnav cannot be used in the statement?

Aucun commentaire:

Enregistrer un commentaire