I have (Joomla) a web page with the following elements;
<section id="sp-top-bar">
<!-- html content -->
</section>
<section id="sp-footer">
<!-- html content -->
</section>
- The
#sp-top-baris styled viacustom.css- with abackground-color: blue. - The
#sp-footeris styled viatemplate.css- with abackground-color: green.
I am using jquery to force the #sp-top-bar to use the same background colour as is set for #sp-footer in the template.css file. (I know there are others ways to set the colour but I'm experimenting with jquery so please bear with me!).
This is my jquery code, which works.
jQuery(function ($) {
var brand = $('#sp-footer');
var bg = brand.css('background-color');
$("#sp-top-bar").css({
backgroundColor: bg
})
});
My jquery code is in the <head> of the document, after my template.css file.
When my page loads, the #sp-top-bar initially flashes blue for a split second, then successfully changes to the #sp-footer green.
I've had a look at the source code and my template.css file is loading before my jquery code - presumably this is the issue?
Is there anything I can do to avoid this initial background colour flash in the #sp-top-bar?
Thanks