Category: Javascript
Alter .img src
Use querySelector to target the img directly: Why document.getElementById(‘MyCssId’).src doesn’t work As for .text, when you apply an ID to an Elementor widget, it is often applied a level up from the actual displayed image If you use this on the ID: You won’t update it.
Alter .textContent
Use querySelector to target the <p> directly: If your innerHTML includes double quotes or newlines You can use backticks instead of quotes: Why document.getElementById(‘MyCssId’).textContent doesn’t work When you apply an ID to an Elementor widget, it is often applied a level up from the actual displayed text, e.g. for ID=”MyCssId” applied to a Text Editor […]
Alter styling from JavaScript
Elementor Button Widget
Hide objects and sections on page load
Default to all hidden To then display a section
Show / hide section by ID
You can use .style.display as normal, just make sure when you show it you are using ‘flex’ and not ‘inline’ if the element is a flex! Hide it: Show it
