javascript - how to access object property using variable -
i have object
var messages = { 'fullname' : 'tell cool name dude..! e.g. yousuf iqbal', 'username' : 'choose catchy username. remember! should available :)', 'password' : 'choose top secret password special chars, numbers , alphabets', 'repassword' : 'retype password typed. but, don\'t try copy!', 'byear' : 'tell year, in bomb blasted' };
and variable..
var attribute = $('#userinfo form input').attr('name');
now want select messages object property using variable this..
var message = messages.attribute;
but not working.. , have tried following..
var message = messages+'.'+attribute;
square brackets:
message = messages[ attribute ];
Comments
Post a Comment