Need help running JavaScript for an item in an RG. I have a Javascript function that changes the inline styling of an element in HTML on hover; I’m not doing CSS because I need it to be inline.
However, I’m finding I can’t get this to run inside Bubble. I’ve tried using the Javascript to Bubble action with the Toolbox plugin:
Anyone have a suggestion?
Here’s the desired result:
Here’s sample HTML with the “non-Bubble” Javascript that works fine outside of Bubble:
Great question, @lindsay_knowcode. This is part of a content builder I’m designing, which basically lets users create a list of objects (headers, paragraphs, call to action buttons, etc.) and change settings for those objects dynamically (e.g., button radius, color, position). This can’t be done with current Bubble.
I WISH Bubble’s native elements let me set all of these easily dynamically, but they don’t. Hoping the new responsive engine/editor will, but who knows when those will be released to GA.
@jared.gibb , thanks for the response! Haven’t had a chance to test this yet but will let you know once I do. Looks promising, so appreciate the share.
You need to write that JQuery function like this… and then call it.
function color(x) {
$('#rgitem').css("background-color", x);
}
color('red');
or change it using JS as @jarad mention, although don’t copy and paste what he typed since it won’t like those double quotes! Also it needs to be getElementById and not getElementByID as like this… (it’s case sensitive)