jquery - javascript syntax calling object properties -


i'm attempting call msgs.loginusername property, dynamically grabbing "loginusername" html jquery. however, can't figure out how structure syntax work.

the object:

msgs = {     loginusername : "username required.",     loginpassword : "password required." }; 

the call:

function validateelements(_class) { var errors = 0; jquery(_class).each(function() {     if (!validate.required(this)) {         var name = jquery(this).attr('name'); //trouble         alert(msgs.name);                     //trouble         errors += 1;     } }); return errors > 0 ? false : true; } 

try using msgs[name] name = "loginusername" or "loginpassword"

function validateelements(_class) { var errors = 0; jquery(_class).each(function() {     if (!validate.required(this)) {         var name = jquery(this).attr('name'); //trouble         alert(msgs[name]);                     //trouble         errors += 1;     } }); return errors > 0 ? false : true; } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -