Hello … I have made a simple jquery plugin (theoretically) which gets my javscript object and say adds a class to turn the text red.
below is my jquery plugin.
$.fn.extend({
colourer:function(options){
var defaults = {
col:'#ff0000',
}
var options = $.extend(defaults, options);
return this.each(function(){
// code that plugin performs
var obj = $(this),
o = options,
obj.addClass(o.col);
})
}
});
So I use it like so:
$('p').colourer();
What I want to do next is create a non jquery object made with plain javascript - which then I chain my jquery plugin to, so for example I would create a DOM element in my JS, which then applies the plugin, so I can run it like this. myObject.colourer();
Is this possible? how would I go about it …
var myObject = {
name:"Xhtr7",
init:function(){
[COLOR=#555555]var element = document.createElement('h1');[/COLOR]
element.appendChild(document.createTextNode ('The man who mistook his wife for a hat')); }
}
var bang = create.object(myObject);
bang.init().colourer();
}
It doesnt work — but its a start … any takers!? thank you