Hi. I'm writing a plugin for myself and I stuck.I'm trying to use link's id value for calling function and I couldn't figure it out. Here is the sample html, plugin for my question. <div id="sample"> <a href="#" id="apple">Find out more about apples...</a> </div> $.sample = { _init: function(){ return this.each(function() { var item = $(this); item.children('a').bind('click', function() { var functionName = this.id; //this line. I couldn't figure how to call link's id's function it. }); }); }, apple: function() { //function for the link has "apple" as id }; };
I could rewrite plugin but it as to be this way. I thinked to used eval () but i thinked it could be dangerous. any idea?