var foo1,foo2;
switch (fn)
{
case "fade" : foo1 = "fadeOut"; foo2 = "fadeIn"; break;
case "slide" : foo1 = "slideUp"; foo2 = "slideDown"; break;
}
eval("$('.cls1')." + foo1 + "();");
currentSlideIndex = currentSlideIndex + n;
eval("$('.cls1')." + foo2 + "();");
Any better way to achieve this without using eval ? Im not a very big fan of using eval unless absolutely necessary.
As the function names stored in foo1
and foo2
are properties of the object returned by $('.cls1')
, the following should work:
$('.cls1')[foo1]();
Same with foo2
.
$('.cls1')[foo1]();
currentSlideIndex = currentSlideIndex + n;
$('.cls1')[foo2]();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With