I have this object with literal notation (took out unnecessary parts):
var work = { "display": function displayWork(){ for(i in work.jobs){ $('#workExperience').append(HTMLworkStart); var formattedEmployer = HTMLworkEmployer.replace('%data%', work.jobs[i].employer); var formattedTitle = HTMLworkTitle.replace('%data%', work.jobs[i].title); var formattedEmployerTitle = formattedEmployer + formattedTitle; var formattedWorkDates = HTMLworkDates.replace('%data%', work.jobs[i].dates); var formattedWorkLocation = HTMLworkLocation.replace('%data%', work.jobs[i].location); var formattedWorkDescription = HTMLworkDescription.replace('%data%', work.jobs[i].description); $('.work-entry:last').append(formattedEmployerTitle); $('.work-entry:last').append(formattedWorkDates); $('.work-entry:last').append(formattedWorkLocation); $('.work-entry:last').append(formattedWorkDescription); } } };
I tried calling him:
work.display.displayWork(); displayWork(); $(work.display).displayWork();
None of them worked. How do I access this function?
If I put a function outside the literal notation object, I can call it simply with:
displayWork();
javascript function jquery
Steve medley
source share