im a php guy, right now im learning on making my first plugin
heres what im upto
$.plugin.method({
test: 'helloworld'
});
$.plugin.method({
test: 'another helloworld'
})
heres my function or class ?
// class ?
jquery.plugin = function(){
// variables
var test = [];
// function ?
var method = function(params){
test[] = params['test']
}
console.log(test)
}
what im expecting
test = ['helloworld','another helloworld']
can we do that in javascript ? am i getting it right ?
thanks!
In your example you made
plugina function, but in the first snippet you are calling$.plugin.method()and not$.plugin().You’d have to make
pluginan object with amethodproperty:The immediate function ensures that
testis only visible to$.pluginitself. You cannot access it from the outside. If you want to do that, you have to make it a property of$.plugin:I suggest you first read a JavaScript guide [MDN guide] to learn the basics about functions [MDN guide] and objects [MDN guide].