views:

29

answers:

1

Hi everyone,

I (i'll try) explain my problem :p I want to use a variable javascript with php like this:

var Effet = '$effet';

this return: an effet for jquery, exemple: fadeIn

Later in js file, i want to apply the effect on element.

I tryed:

$('div#something').hide().append(data).Effet+'(1000)';

But this doesn't work... i can't get fadein(1000);

Any idea?

Thx for response

PS: Thx to all contributors and creators of this website, really nice job!

+1  A: 

You can do it like this:

var Effect = "fadeIn", data="things";
$('div#something').hide().append(data)[Effect](1000);

You can give it a try here, in JavaScript these are equivalent:

object.propOrFunctionName
object["propOrFunctionName"]
Nick Craver
Work very well!Thx, this is exacly what i search :)
The_Death_Raw