If I have an element on the page like this …
<span data-function=\"DoSomething\">Click</span>
… and i put this in my page header …
$(document).ready(function()
{
$(\'[data-function]\').each(function()
{
var fName = $(this).attr(\'data-function\');
$(this).click(fName);
});
});
… what goes in place of the comment produce the desired effect of executing the function called \”DoSomething\”.
Note:
I no the code above wont work, my question is how to make this work (translate \’DoSomething\’ in to DoSomething();)
Any ideas guys?





Rating:
The post jquery – Calling Javascript Functions by name appeared first on Javascript ASK.
via Javascript ASK http://javascriptask.phpfogapp.com/jquery-calling-javascript-functions-by-name.html
No comments:
Post a Comment