# Possible to use custom JS to set a state on page?

**URL:** <https://forum.bubble.io/t/possible-to-use-custom-js-to-set-a-state-on-page/25080>\
**Category:** Plugins\
**Created:** [February 27, 2018, 9:09pm UTC](https://forum.bubble.io/t/possible-to-use-custom-js-to-set-a-state-on-page/25080 "2018-02-27T21:09:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kramwe](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/kramwe/32/10102_2.png) [@kramwe](https://forum.bubble.io/u/kramwe)\
**Post date:** [February 27, 2018, 9:09pm UTC](https://forum.bubble.io/t/possible-to-use-custom-js-to-set-a-state-on-page/25080/1 "2018-02-27T21:09:12Z")

</div>

Is it possible to use custom JS to set a state on a page that is recognized by a condition in Bubble?

For example, I want to hide an element on a page until some custom JS runs. Once done, I’d like this custom JS to unhide the element.

I have a condition on an element.

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/2/a/2a40e33affaa5abb7d02e9d2581d451b1c1f6bcf.png)

With custom JS can I do something like…so which will trigger the condition?  
var showBackgroundImage = “yes”;

---

<div class="post-metadata">

**Author:** ![sridharan.s](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sridharan.s/32/17881_2.png) [@sridharan.s](https://forum.bubble.io/u/sridharan.s)\
**Post date:** [February 28, 2018, 8:21pm UTC](https://forum.bubble.io/t/possible-to-use-custom-js-to-set-a-state-on-page/25080/2 "2018-02-28T20:21:23Z")

</div>

Yes. Here’s how:

- Have your javascript set a variable’s value
- Use the Javascript to Bubble feature (in toolbox, I believe) to get that value into Bubble
- Then, set a workflow to run when the Javascript to Bubble’s value is, say, yes… and have an action within that workflow set a custom state.

---

<div class="post-metadata">

**Author:** ![kramwe](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/kramwe/32/10102_2.png) [@kramwe](https://forum.bubble.io/u/kramwe)\
**Post date:** [February 28, 2018, 8:32pm UTC](https://forum.bubble.io/t/possible-to-use-custom-js-to-set-a-state-on-page/25080/3 "2018-02-28T20:32:19Z")

</div>

thanks.
