How to put an attribute onClick in .w-lightbox-backdrop

I need to insert an onClick attribute to .w-lightbox-backdrop, but I can’t access it.

while I can add it only through the inspect tool


what would be the value for the onClick attribute ?

To dynamically create an attribute, you will have to use some JavaScript.
The idea is to, when the DOM has finished loading, create an array of all your class element, then create an attribute “onClick”, asign it a value then apend that attribute into each of the items of your array via a for loop.

Hi, @anthonysalamin thanks for the answer.

to be more specific, I need the intro video to stop when opening the lightbox and to continue again when closing the lightbox

the attribute must contain a function, for example onClick=“playVid()”, it is pre-created in custom code embed ↓

I see.
I create a codepen for you to have a look at. If you look at the console, you will notice the onClick attribute has been added to all div.

Here is the JavaScript you’ll need

// 🍉 wait for the DOM to be loaded
document.addEventListener("DOMContentLoaded", event => {

// 🥭 collect all items inside an array + set the new attribute
function createOnClick() {
  let items = document.getElementsByClassName("w-lightbox-backdrop");
  for (let i = 0; i < items.length; i++) {
    let item = items[i];
    item.setAttribute("onClick", "playVid()");

Hope that helps.