This is my script, for some reason when i use contactForm.container[contactForm.container.config.effect](); it says “contactForm.container.config is undefined ” … I can very well see it defined! what am i doing wrong? Thank you
<script>
(function(){
$('html').addClass('js');
var contactForm ={
container: $('#contact'),
config: {
effect:'slideToggle'
},
init: function(){
$('<button></button>',{
text: 'Contactame'
})
.insertAfter('article:first')
.on('click', this.show);
},
show: function(){
contactForm.close.call(contactForm.container);
contactForm.container[contactForm.container.config.effect]();
},
close: function(){
var $this = $(this);
$('<span class=close>X</span>')
.prependTo(this)
.on('click',function(){
$this.hide();
})
}
};
contactForm.init();
})();
</script>
configis not a child ofcontainer. They’re siblings.You seem to want: