私はモジュールパターンを通してプライベート変数の値を設定しようとしています。 私が言っていることは、$ contentを私がperson.contentに渡す値に設定していることです。しかし、これは動作していないようです。なぜなら、値を警告すると、私には未定義のエラーが出るからです。モジュールパターン内の変数を更新する
$(document).ready(function(){
person.content = $('#content');
person.getContent();
});
// Person Module
var person = (function(){
var $content;
function getContent(){
alert('content = '+$content.find(':first h2').text());
}
return {
content: $content,
getContent : getContent,
}
}());