Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
You ought to be using some-sort of developer tool to debug JavaScript, like the one built-in to Google Chrome. Then look at the ‘console’ and check whether any errors are being thrown.
You need to use jQuery no-conflict wrappers too.
I’ve changed code to get no errors
jQuery(function($) {
if($(document).height() <= $(window).height()) {
$('#header').css({ 'height': ($(window).height()) });
$(window).resize(function(){
$('#header').css({ 'height': ($(window).height()) });
});
}
});
but its still not working, any ideas?
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Can you provide a working example of the issue (link to a webpage)?
http://550d.webnice.pl/ I’ve changed a bit classes
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
I can’t find your jQuery (from this thread) on that webpage. Is it declared in particular .js
file?
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Sorry, I don’t think that jQuery is in that file http://550d.webnice.pl/wp-content/themes/simplecorp/library/js/scripts.js
Edit: Nevermind – I was looking at the wrong file ;(
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Do you need to wrap your jQuery in a ready
function?
E.g;
jQuery(document).ready(function($) {
if($(document).height() <= $(window).height()) {
$('#header').css({ 'height': ($(window).height()) });
$(window).resize(function(){
$('#header').css({ 'height': ($(window).height()) });
});
}
});
it doenst help
$(window).height() is working but .css doesnt
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
I ran these two functions in my browser’s console and it returned this;
jQuery(document).height()
1816 //returned value
jQuery(window).height()
340 //returned value
So the Document height isn’t less than or equal to the Window height.
Is this the same for you? If so, this is why your code appears not to be working.
Ok i removed that code, I am noob at js
jQuery(function($) {
$(window).resize(function(){
$('body').css({ 'background-size': 100% ($(window).height()) });
});
$('.intro-page h2').text($(window).height() + 'px') ;
});
what is wrong now?
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
This line
$('body').css({ 'background-size': 100% ($(window).height())
Appears to be writing an invalid style;
background-size: 100% 340
I got:
background-size: 100px auto;
how to do it well?
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Actually, I had that too.
Umm, what do you want to happen? What style are you trying to get when the browser resizes?
i want to get background to cover visible area in browse like here http://www.shegy.nazwa.pl/themeforest/exit/normal/
so i need to get background-cover: 100% jQuery(window).height();