how to use var value name as function name in JavaScript -
hi guys can use value function name in javascript? have functions same name input values such as:
var ta = $('li.ramin.active').attr("id"); var act = $('input[name="'+ta+'_acceptdeny"]:checked').val(); act(freq, meid); // question
in way have error "uncaught typeerror: act not function" yes know act not function want use var act value function name!! need know how can that? all
you can use window[act](freq, meid)
thanks justin niessner pointing out work if act
defined in global scope. use eval
, however, considered unsafe.
Comments
Post a Comment