我有这个文字符号对象(拿出不相关的部分):
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); } } };
我试过用它调用它:
work.display.displayWork(); displayWork(); $(work.display).displayWork();
displayWork();