# Chain my jquery plugin to my javscript object

**URL:** <https://forum.kirupa.com/t/chain-my-jquery-plugin-to-my-javscript-object/329329>\
**Category:** Uncategorized\
**Created:** [August 14, 2012, 6:07pm UTC](https://forum.kirupa.com/t/chain-my-jquery-plugin-to-my-javscript-object/329329 "2012-08-14T18:07:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)\
**Post date:** [August 14, 2012, 6:07pm UTC](https://forum.kirupa.com/t/chain-my-jquery-plugin-to-my-javscript-object/329329/1 "2012-08-14T18:07:51Z")

</div>

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.

```auto
$.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:

```auto
$('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 …

```auto
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 🙂
