We written some function in jquery.When user click on each div we need to call each function dynamically.
<div class="test" id="test1"></div>
<div class="test" id="test2"></div>
function test1(){
alert('test1');
}
function test2(){
alert('test2');
}
$(".test").on("click",function(){
var function_name=$(this).attr("id");
window[function_name]();
});
But this code is not working end the error is window[function_name] is not a function . How to solve this
also Please suggest another 2,3 methods