calling a jQuery function named in a variable

前端 未结 6 726
小蘑菇
小蘑菇 2020-12-10 01:21

I have several jQuery function like function setOne(); setTwo(); setThree();

and a variable var number that values respectively \"one\", \

6条回答
  •  死守一世寂寞
    2020-12-10 01:57

    If the variable details the actual name of the JQuery function and you want to apply the function to a DOM element like 'body', you can do the following:

     $('body')['function-name']('params');
    

提交回复
热议问题