Dear Lorenzo
@lorenzomala
Javascript or jQuery must first be placed inside a "newpage event" when adding to Lay Theme https://laytheme.com/documentation.html#custom-javascript
Newpage Events
Because your Lay Theme website is a "Single Page" JavaScript application you cannot just use jQuery(document).ready(ā¦) to execute your js because the ready event only fires once when the website loads the first time.
Since Lay Theme 1.056 you can use a JavaScript event to execute your own JavaScript whenever a project, page or category is visited. The event is called "newpageshown". It will trigger when a new project, page or category has rendered.
window.laytheme.on("newpageshown", function(layoutObj, type, obj){
// your code would go here
});
layoutObj is a an empty object. This used to contain the - layout's JSON, but was deprecated.
type can be either "project", "page" or "category".
obj is WordPress' post, page or term object. These objects contain general information like ids and slugs.
Any jQuery '$' symbols must be written in full "jQuery" e.g
$(addClass); becomes jQuery(addClass);
Custom Code is most likely to be placed in "Custom <head> Content" in > Lay Options > Custom CSS & HTML >
Best wishes Lorenzo & have a great day š
Richard