so if you have this html:
<li id='hi'></li>
and let's say this jquery:
var obj = {
hi: {
role:'something'
},
hello: {
role: 'something'
}
}
$('li').click(function(e) {
var nameTrig = e.target.getAttribute('id');
alert(obj.nameTrig.role);
});
I click the li => so if i call obj.nameTrig.role
, it should be 'something'
?
I tried this and in the console it said: Uncaught TypeError: Cannot read property 'name' of undefined
Please help thanks