When I perform Scroll down action on your site. Following error is printed on the console :

(index):200 Uncaught SyntaxError: Invalid or unexpected token

For the statement below :

$(header#main-header).css('background-color', 'red');

Now when I tried doing this using just JS it works fine. Just open the console and try it out.

document.getElementById("main-header").setAttribute("style","background-color:red");
Answer from damitj07 on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_htmldom_css.asp
JavaScript DOM CSS
The HTML DOM allows JavaScript to change the style of HTML elements. To change the style of an HTML element, use this syntax: document.getElementById(id).style.property= new style ...
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ API โ€บ HTMLElement โ€บ style
HTMLElement: style property - Web APIs | MDN
For example, an element with style ... styles to an element without altering other style values, it is generally preferable to set individual properties on the CSSStyleProperties object....
๐ŸŒ
JavaScript Tutorial
javascripttutorial.net โ€บ home โ€บ how to add styles to an element
How to Add Styles to an Element - JavaScript Tutorial
May 28, 2021 - First, select the element by using DOM methods such as document.querySelector(). The selected element has the style property that allows you to set the various styles to the element.
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ prop_html_style.asp
HTML DOM Element style Property
... JavaScript syntax is slightly different from CSS syntax: backgroundColor / background-color. See our Full Style Object Reference. Use this style property instead of the The setAttribute() Method, to prevent overwriting other properties in ...
Find elsewhere
๐ŸŒ
tutorialstonight
tutorialstonight.com โ€บ js โ€บ js-dom-style
add style to element using javascript
Let's change the color of an element with "id1" in example below. ... In the above example, you set the new style to the paragraph directly using javascript, but you can also set the new style to any element when an event is fired.
๐ŸŒ
W3C
w3.org โ€บ wiki โ€บ Dynamic_style_-_manipulating_CSS_with_JavaScript
Dynamic style - manipulating CSS with JavaScript - W3C Wiki
July 9, 2015 - The style object has attributes that correspond to the different CSS properties we set. For example, style.color returns the colour that element has set on it. By calling element.style.color = "red"; you can apply the style change dynamically. Below is a function that turns an elementโ€™s colour to red when you pass it the elementโ€™s id.
๐ŸŒ
30 Seconds of Code
30secondsofcode.org โ€บ home โ€บ javascript โ€บ browser โ€บ get, set or add styles to an html element
Get, set or add styles to an HTML element with JavaScript - 30 seconds of code
February 21, 2024 - const addStyles = (el, styles) => Object.assign(el.style, styles); addStyles(document.getElementById('my-element'), { background: 'red', color: '#ffff00', fontSize: '3rem' }); ... Get started with manipulating CSS in the browser, using JavaScript.
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ javascript โ€บ javascript-change-style-of-html-element
JavaScript - Change style of HTML element - HTMLElement.style
September 6, 2021 - JavaScript HTMLElement.style - To change style of HTML Element programmatically, assign custom style value HTMLElement.style. Example : document.getElementById('idv').style = 'color:#f00;'. Syntax and Try Online Examples are provided to get hands on.
๐ŸŒ
Go Make Things
gomakethings.com โ€บ two-ways-to-set-an-elements-css-with-vanilla-javascript
Two ways to set an element's CSS with vanilla JavaScript | Go Make Things
August 23, 2017 - The style property adds styles inline on the element. <div id="some-element" style="color: purple; background-color: #e5e5e5; height: 150px;"> Hello, world!
๐ŸŒ
Soshace
soshace.com โ€บ blog โ€บ css โ€บ setting css styles with javascript
Setting CSS Styles with JavaScript โ€” Soshace
January 10, 2025 - ... To do the same in Javascript, first, we need to access the title element. To access any element in Javascript, there are some methods like these: Select an element by its Id โ€” document.getElementById(โ€œidโ€)
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ met_element_setattribute.asp
HTML DOM Element setAttribute() Method
It is possible to add a style attribute with a value to an element, but it is not recommended because it can overwrite other properties in the style attribute. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ยท If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com ยท HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
๐ŸŒ
Quora
quora.com โ€บ How-can-you-change-the-style-of-an-HTML-element-using-JavaScript
How to change the style of an HTML element using JavaScript - Quora
Answer (1 of 3): The DOM (Document Object Model) is an interface between HTML and JavaScript. You can not only change style of HTML elements but you can also create, delete, add, replace elements using DOM methods. The DOM methods selects html elements by their id, class or element name then per...
๐ŸŒ
JavaScript Tutorial
javascripttutorial.net โ€บ home โ€บ javascript dom โ€บ javascript style
JavaScript Style: Setting Inline CSS Properties of an HTML Element
November 15, 2024 - The following example uses the ... language: HTML, XML (xml) How it works: First, select the paragraph element whose id is content by using the querySelector() method....
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ how-to-change-style-attribute-of-an-element-dynamically-using-javascript
How to change style attribute of an element dynamically using JavaScript ? | GeeksforGeeks
August 3, 2023 - In this article, we will see how ... through examples.Approach 1: In this approach, a function is called when the button is clicked, which changes the ID of the element to id-5....