jquery string to function convert

后端 未结 2 957
孤街浪徒
孤街浪徒 2021-01-22 21:38

is this possible?

I will change
var
2条回答
  •  梦谈多话
    2021-01-22 22:10

    you can use new Function MDN

    body:

    On Load raise an Alert

    js:

    var myFunc = myFunc || document.getElementById('MyFunc'),
            hello = new Function( myFunc.getAttribute('func'));
        hello.call(this);
    

    give it a try:

    http://jsfiddle.net/msLsy/

    Hope it helps!

提交回复
热议问题