When you need to write javascript, create a plugin. Do not write your own code in global namespace your own js code should be unobtrusive. This plugin helps doing theese two steps.
$(document).ready(function() {
$(this).drapper();
})
Add jquery_drapper.js to the project. Mark DOM elements that you want to change with data-decorate attribute and initiate the plugin.
$.drappers = $.extend($.drappers, {
mydrapper: function() {
console.log("The special code, writing for html elements with drapper type 'myDrapper'");
if(this.config.specialTactics) {
$(this).css({
border: '1px solid black'
});
}
$(this).click(function() {
$(this).hide();
});
}
})
Drappers should be added in $.drappers object. Use jQuery.extend for adding a new drapper. Here is an example.
Here you could put a live example if your project happens to be something to do with web development, or maybe you could insert some images.