in the Divi page builder on WordPress you can add and Class or ID to a section. But I can’t figure out a way to add any inline code to the tags that the page builder then puts in the html that makes the page.
I’m trying to add the midnight.js plugin to a WordPress site using Divi and to do so I need to add inline javascript code…
<div data-midnight="white">
This is the div code that the divi builder puts on the page:
<div class="et_pb_section et_pb_section_parallax et_pb_section_3 et_section_regular">
I need to add data-midnight="white"
to the end of this code
Does anyone know a way I could do this?
2
Answers
If you’re just trying to add inline code, you can use the code module that Divi provides. Just make sure you put any JavaScript inside
<script>
tags.You could try using
setAttribute()
. So if you’re wanting to change “div_current_id” to “date-midnight” as the ID, you could do:If you add this in a js file that’s loaded or within a
<script>
tag into the HTML code, it should add the desired attribute to that element:It selects the element/s which has/have all those classes combined and adds the attribute with the indicated vaue to it.