# Set trigger on element outside the animated element Interaction

**URL:** <https://forum.pinegrow.com/t/set-trigger-on-element-outside-the-animated-element-interaction/6153>\
**Category:** Pinegrow Interactions Add-on\
**Created:** [January 14, 2022, 9:50am UTC](https://forum.pinegrow.com/t/set-trigger-on-element-outside-the-animated-element-interaction/6153 "2022-01-14T09:50:36Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![AllMediaLab](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/allmedialab/32/2079_2.png) [@AllMediaLab](https://forum.pinegrow.com/u/AllMediaLab)\
**Post date:** [January 14, 2022, 5:03pm UTC](https://forum.pinegrow.com/t/set-trigger-on-element-outside-the-animated-element-interaction/6153/21 "2022-01-14T17:03:59Z")

</div>

@abirana

Is there a way to trigger the hours script at the bottom of the test page in Interactions!?

Thanks!

David

---

<div class="post-metadata">

**Author:** ![abirana](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/abirana/32/4162_2.png) [@abirana](https://forum.pinegrow.com/u/abirana)\
**Post date:** [January 14, 2022, 5:28pm UTC](https://forum.pinegrow.com/t/set-trigger-on-element-outside-the-animated-element-interaction/6153/22 "2022-01-14T17:28:19Z")

</div>

I don’t think I understood what you meant. Can you please elaborate more?

---

<div class="post-metadata">

**Author:** ![AllMediaLab](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/allmedialab/32/2079_2.png) [@AllMediaLab](https://forum.pinegrow.com/u/AllMediaLab)\
**Post date:** [January 14, 2022, 5:31pm UTC](https://forum.pinegrow.com/t/set-trigger-on-element-outside-the-animated-element-interaction/6153/23 "2022-01-14T17:31:53Z")

</div>

@abirana

I mean that when I click the Interactions trigger the hours script at the bottom is activated so you see if the shop is open or closed. Now it only works on page load. So I wrapped both click events in a function and it works perfect.

I added the function to both click events is this how it’s supposed to be done?:

Now I can see the active day and close or open indication on click.

Is there a better way to do this?

```auto
 <a href="#menu-toggle" onclick="startHourScript()" class="btn float-left text-danger" id="menu-toggle-2" data-pg-ia='{"l":[{"name":"clickCrossClosePanel","trg":"click","t":"$#hours-open-wrap","a":{"l":[{"t":"","l":[{"t":"set","p":0,"d":0,"l":{"x":"0%"},"e":"Power1.easeOut"},{"t":"tween","p":0,"d":3,"l":{"x":"100%"},"e":"Power1.easeOut"}]}]},"pdef":"true"}]}' data-pg-ia-show>&#10060;</a>

```

```auto
<a href="#menu-toggle" onclick="startHourScript()" class="js-scroll-trigger text-danger" style="font-size: 3em;" id="menu-toggle" data-pg-ia='{"l":[{"name":"slideInFromRight","trg":"click","t":"$#hours-open-wrap","a":{"l":[{"t":"","l":[{"t":"tween","p":0,"d":0,"l":{"x":"100%","autoAlpha":0},"e":"Power1.easeOut"},{"t":"tween","p":0.35,"d":0.76,"l":{"x":"0%","autoAlpha":1},"e":"Power1.easeOut"}]}]},"pdef":"true"}]}'> <i class="fad fa-clock fa-2x"></i> CLICK TO OPEN PANEL</a> 

```

```auto
function startHourScript() {

let currentDate = new Date();
let weekday = [];
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";

let currentDay = weekday[currentDate.getDay()];

let currentTimeHours = currentDate.getHours();
currentTimeHours = currentTimeHours < 10 ? "0" + currentTimeHours : currentTimeHours;
let currentTimeMinutes = currentDate.getMinutes();
let timeNow = currentTimeHours + "" + currentTimeMinutes;

let currentDayID = "#" + currentDay; //gets todays weekday and turns it into id
$(currentDayID).toggleClass("today"); //this works at hightlighting today

let openTimeSplit = $(currentDayID).children('.opens').text().split(":");

let openTimeHours = openTimeSplit[0];
openTimeHours = openTimeHours < 10 ? "0" + openTimeHours : openTimeHours;

let openTimeMinutes = openTimeSplit[1];
let openTimex = openTimeSplit[0] + openTimeSplit[1];

let closeTimeSplit = $(currentDayID).children('.closes').text().split(":");

let closeTimeHours = closeTimeSplit[0];
closeTimeHours = closeTimeHours < 10 ? "0" + closeTimeHours : closeTimeHours;

let closeTimeMinutes = closeTimeSplit[1];
let closeTimex = closeTimeSplit[0] + closeTimeSplit[1];

if (timeNow >= openTimex && timeNow <= closeTimex) {
    $(".openorclosed").toggleClass("open");
} else {
    $(".openorclosed").toggleClass("gesloten");
} }

```

[Previous page](https://forum.pinegrow.com/t/set-trigger-on-element-outside-the-animated-element-interaction/6153.md?page=1)
