Variable in jquery animate command
Posted: Tue Jul 29, 2025 3:53 pm
Hey There,
I fighting with a jquery script and I'm losing.
So I need some help.
What I want is to create a variable containing css setting
Then I want to use this variable in a jquery animate command:
I searched the internet and tried, tried and tried but .... without any luck.
This is what I tought would work (but isn't).
In smarty template I set a variable (stylecss_start) :
Then I move this variable to jquery and check if it is set :
The alert shows the "opacity: 1" so the variable is set.
Then I want to use this variable in the jquery animation :
I tried the following (I found on the internet):
Nothing seems to work.
The jquery is part of the tpl file so no extra jquery file to import.
Without the variable it is working
Please advise/help.

I fighting with a jquery script and I'm losing.
So I need some help.
What I want is to create a variable containing css setting
Then I want to use this variable in a jquery animate command:
I searched the internet and tried, tried and tried but .... without any luck.
This is what I tought would work (but isn't).
In smarty template I set a variable (stylecss_start) :
Code: Select all
{assign var="stylecss_start" value='opacity: 1'}
Code: Select all
var start_stylecss = {/literal}"{$stylecss_start}"{literal};
alert(start_stylecss);
Then I want to use this variable in the jquery animation :
Code: Select all
$(".myPopup").animate( start_stylecss );
Code: Select all
$(".myPopup").animate( { start_stylecss } );
$(".myPopup").animate( { + start_stylecss + } );
$(".myPopup").animate( "start_stylecss" );
The jquery is part of the tpl file so no extra jquery file to import.
Without the variable it is working
Code: Select all
$(".myPopup").animate( {opacity: 1});
