<div class='cmenu esc' id='cma'>
<div class='cmitem' data-fn='itemcut'>CUT</div>
<div class='cmitem' data-fn='itempaste'>PASTE</div>
<div class='cmitem' data-fn='itemdel'>DELETE</div>
</div>
js
$('.cmitem').click(function(){
var fn = $(this).attr('data-fn');
$(window)[fn]();
});
function itemcut(){
console.log('test');
}
Error:
Uncaught TypeError: $(...).fn is not a function
So how to call a function this way ?
window[fn](). Remove the jQuery stuff from your call.