{"id":20819966,"url":"https://github.com/elo7/doc-amd","last_synced_at":"2025-05-07T15:41:28.879Z","repository":{"id":29949244,"uuid":"33495785","full_name":"elo7/doc-amd","owner":"elo7","description":"doc.js is a small library to manipulate the DOM in any browser. We focused on the most used and common use cases to create this. This library uses amd structure.","archived":false,"fork":false,"pushed_at":"2021-08-02T08:31:53.000Z","size":151,"stargazers_count":5,"open_issues_count":10,"forks_count":0,"subscribers_count":96,"default_branch":"master","last_synced_at":"2025-04-09T21:41:47.189Z","etag":null,"topics":["amd","doc","doc-amd","dom","dom-element","event-listener","front-end","javascript","lib","martell","nymeros","queryselector","selector"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elo7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-06T17:43:38.000Z","updated_at":"2024-08-30T01:57:03.000Z","dependencies_parsed_at":"2022-08-30T16:11:38.352Z","dependency_job_id":null,"html_url":"https://github.com/elo7/doc-amd","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fdoc-amd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fdoc-amd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fdoc-amd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fdoc-amd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elo7","download_url":"https://codeload.github.com/elo7/doc-amd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252907818,"owners_count":21823278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amd","doc","doc-amd","dom","dom-element","event-listener","front-end","javascript","lib","martell","nymeros","queryselector","selector"],"created_at":"2024-11-17T22:07:56.524Z","updated_at":"2025-05-07T15:41:28.819Z","avatar_url":"https://github.com/elo7.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Doc-amd\n\n_Doc-amd library_\n\ndoc.js is a small library to manipulate the DOM in any browser. We focused on the most used and common use cases to create this. This library uses [amd](http://en.wikipedia.org/wiki/Asynchronous_module_definition) structure.\n\n[![Build Status](https://travis-ci.org/elo7/doc-amd.svg?branch=master)](https://travis-ci.org/elo7/doc-amd)\n\n#### Why?\n\nWe needed a small footprint alternative for jquery and still have the ease-of-use for the most commonly used methods on it.\n\nThen, we built it from scratch.\n\n## Installation\n\nInstall with [Npm](https://www.npmjs.com/): `npm install elo7-doc-amd`\n\n## Dependencies\n\nDoc-amd depends on an [amd](http://en.wikipedia.org/wiki/Asynchronous_module_definition) implementation. We suggest [define-async](https://www.npmjs.com/package/define-async) implementation for dependency lookup.\nDoc-amd also depends on [events-amd](https://www.npmjs.com/package/elo7-events-amd).\n\n## Methods\n\n#### doc\n`doc(querySelector)`\n`doc(HTMLCollection)`\n`doc(NodeList)`\n`doc(Array)`\n`doc(Node)`\n\n###### Description:\nReturns a Doc object with all the methods below.\n\n###### Parameters:\n\u003e querySelector: String //A CSS selector. Note that, if it is a class name with dots, the dots must be escaped. E.g.: doc(\".my\\\\.class\")\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('.link')\n\tdoc('#link')\n\tdoc('a')\n\tdoc('li \u003e a')\n\tdoc(document.body.children)\n\tdoc(document.body.childNodes)\n\tdoc(document.body)\n\tdoc([document.head, document.body])\n});\n```\n\n#### els\n`.els()`\n\n###### Description:\nReturns an array with matched Elements.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('a').els\n\tdoc('li .links').els[1]\n});\n```\n\n#### size\n`.size`\n\n###### Description:\nReturns the length of elements.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tvar numberOfElements = doc('a').size;\n});\n```\n\n#### each\n###### Usage:\n`.each(callback)`\n\n###### Description:\nIterate through a Doc object, executing a Function on each one of them.\n\n###### Parameters:\n\u003e callback: Function() //A function to call.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('a').each(function(el){\n\t\tconsole.log(el) //DOM Element\n\t});\n});\n```\n\n#### data\n`.data(key [,value])`\n\n###### Description:\nGet or set the value of a data-* attribute\n\n###### Parameters:\n\u003e key: String //A string naming the piece of data to set or get.\n\n\u003e value: String //The new data value.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('a.link').data('bar'); //Get the value of the attribute data-bar\n\tdoc('a.link').data('foo','test'); //Set the value of the attribute data-foo\n});\n```\n\n#### val\n`.val([value])`\n\n###### Description:\nGet or set the value of the element\n\n###### Parameters:\n\u003e value: String //The new value.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('input[name=email]').val(); //Get the value of the element\n\tdoc('input[name=email]').val('test@email.com'); //Set the value of the element\n});\n```\n\n#### html\n`.html([value])`\n\n###### Description:\nGet or set the value of the inner html\n\n###### Parameters:\n\u003e value: String //The new value.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('div.content').html(); //Get the inner html of the element\n\tdoc('section').html('\u003cp\u003eLorem ipsum sit amet in dollor, consecteur\u003c/p\u003e'); //Set the inner html of the element\n});\n```\n\n\n#### prepend\n`.prepend(element)`\n\n###### Description:\nPrepends the existing DOM element, doc-amd element or text as child of the Doc object\n\n###### Parameters:\n\u003e element: Element //The element you want to prepend as a child of your selector.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tvar div = document.createElement('div');\n\tdoc('body').prepend(div); //Prepend the new DOM element as child of the Doc object\n\tdoc('body').prepend($('div.content')); //Prepend the exist DOM element as child of the Doc object\n\tdoc('body').prepend('\u003cp\u003eText here\u003c/p\u003e'); //Prepend text HTML as child of the Doc object\n});\n```\n\n#### append\n`.append(element)`\n\n###### Description:\nAppend the DOM element as child of the Doc object\n\n###### Parameters:\n\u003e element: Element //The element you want to append as a child of your selector.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tvar div = document.createElement('div');\n\tdoc('body').append(div); //Append the new DOM element as child of the Doc object\n\tdoc('body').append($('div.content').first()); //Append the exist DOM element as child of the Doc object\n});\n```\n\n#### text\n`.text(value)`\n\n###### Description:\nSet the inner text of the element\n\n###### Parameters:\n\u003e value: String //New value for the text of the element.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('.content').text('Lorem ipsum'); //Set the inner text of the element\n});\n```\n\n#### attr\n`.attr(key [,value])` or `.attr(object)`\n\n###### Description:\nGet or set the value of the attribute\n\n###### Parameters\n\u003e key: String //A string naming the attribute to set or get.\n\u003e value: String //The new value of the attribute.\n\nor\n\n\u003e value: Object //A javascript object\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('input[name=email]').attr('disabled'); //Get the value of attribute\n\tdoc('input[name=email]').attr('type','password'); //Set the value of attribute\n\tdoc('input[name=email]').attr({'required': true, 'maxlength': 5}); //Set each index and value from object\n});\n```\n\n#### hasClass\n`.hasClass(class)`\n\n###### Description:\nVerify if the Doc object has the CSS class\n\n###### Parameters:\n\u003e class: String //The CSS class of the element. Return boolean.\n\n###### Sample:\n``` html\n\u003cdiv class='container'\u003eLorem\u003c/div\u003e\n```\n\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('div').hasClass('container'); //Returns true\n\tdoc('div').hasClass('content'); //Returns false\n});\n```\n\n#### addClass\n`.addClass(class)`\n\n###### Description:\nAdds a CSS class to the element.\n\n###### Parameters:\n\u003e class: String //The CSS class of the element.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('div').addClass('content'); //Adds .content class to all divs\n\tdoc('div').addClass('hide active'); //Adds .hide and .active class to all divs\n});\n```\n\n#### removeClass\n`.removeClass(class)`\n\n###### Description:\nRemoves the CSS class from the element.\n\n###### Parameters:\n\u003e class: String //The CSS class of the element.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('div').removeClass('content'); //Removes .content class from all divs\n\tdoc('div').removeClass('hide active'); //Removes .hide and .active class from all divs\n});\n```\n\n#### toggleClass\n`.toggleClass(class)`\n\n###### Description:\nAdds or removes the CSS class from the element.\n\n###### Parameters:\n\u003e class: String //The CSS class you want to add or remove.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('div').toggleClass('content'); //Adds or remove .content class from all divs\n\tdoc('div').toggleClass('hide active'); //Adds or remove .hide and .active class from all divs\n});\n```\n\n#### removeItem\n`.removeItem()`\n\n###### Description:\nRemove the element from the DOM.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('#box').removeItem(); //Remove the element from the DOM.\n});\n```\n\n### find\n`.find(querySelector)`\n\n###### Description:\nGet the descendants of the Doc object, filtered by querySelector.\n\n###### Parameters:\n\u003e querySelector: String //Returns the query's matched elements.\n\n###### Sample:\n``` html\n\u003cform\u003e\n\t\u003cfieldset\u003e\n\t\t\t\u003cinput name='name' /\u003e\n\t\t\t\u003cinput name='email' /\u003e\n\t\u003c/fieldset\u003e\n\u003c/form\u003e\n```\n\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('form').find('input[name=email]'); //Returns the Doc object input\n\tdoc('form').find('input'); //Returns the Doc object (containing all input elements)\n});\n```\n\n### closest\n`.closest(querySelector)`\n\n###### Description:\nGet the first ascendant of the Doc object, filtered by querySelector.\n\n###### Parameters:\n\u003e querySelector: String //Should not be a composite. e.g. \"#id .class\" or \"tag.class\" due to compatibility issues. Prefer simple selectors. e.g. '.class'. Returns the query's matched elements.\n\n###### Sample:\n``` html\n\u003cform\u003e\n\t\u003cfieldset\u003e\n\t\t\t\u003cinput name='name' /\u003e\n\t\t\t\u003cinput name='email' /\u003e\n\t\u003c/fieldset\u003e\n\u003c/form\u003e\n```\n\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('input').closest('form'); //Returns the Doc object form.\n});\n```\n\n#### filter\n`.filter(attribute || callback)`\n\n###### Description:\nThere are two use cases for this method.\nIf you use an attribute, it will return a Doc object containing all elements containing the attribute.\nIf you use callback, _filter()_ will test each element in the set against your callback and return boolean for each. The result will be a Doc object matching your Function.\n\n###### Parameters:\n\u003e attribute: String //A string containing an attribute to match the current set of elements against.\n\n\u003e callback: Function() //A function used as a test for each element in the set. This is the current DOM element.\n\n###### Sample:\n\u003cform\u003e\n\t\u003cfieldset\u003e\n\t\t\t\u003cinput name='name' required /\u003e\n\t\t\t\u003cinput name='email' class='required' /\u003e\n\t\u003c/fieldset\u003e\n\u003c/form\u003e\n\n``` js\ndefine(['doc'], function(doc) {\n\tvar requiredInputs = doc('form input').filter('required'); //Returns all inputs with required attribute\n\tvar requiredClassInputs = doc('form input').filter(function(element){\n\t\treturn element.hasClass('required');\n\t}); //Returns all inputs with required class\n});\n```\n\n#### first\n`.first()`\n\n###### Description:\nReturns the first DOM element from the query list.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('div').first(); //Returns the first DOM element from the query list\n});\n```\n\n#### last\n`.last()`\n\n###### Description:\nReturns the last DOM element from the query list.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('div').last(); //Returns the last DOM element from the query list\n});\n```\n\n#### previous\n`.previous()`\n\n###### Description:\nReturns the query's previous Doc object.\n\n###### Sample:\n``` html\n\u003cform\u003e\n\t\u003cfieldset\u003e\n\t\t\t\u003cinput name='name' /\u003e\n\t\t\t\u003cinput name='email' /\u003e\n\t\u003c/fieldset\u003e\n\u003c/form\u003e\n```\n\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('input[name=email]').previous() //Returns the previous Doc object === input[name=name]\n\tdoc('input[name=name]').previous() //Returns the previous Doc object === undefined\n});\n```\n\n#### next\n`.next()`\n\n###### Description:\nReturns the query's next Doc object.\n\n###### Sample:\n``` html\n\u003cform\u003e\n\t\u003cfieldset\u003e\n\t\t\t\u003cinput name='name' /\u003e\n\t\t\t\u003cinput name='email' /\u003e\n\t\u003c/fieldset\u003e\n\u003c/form\u003e\n```\n\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('input[name=name]').next() //Returns the next Doc object === input[name=email]\n\tdoc('input[name=email]').next() //Returns the next Doc object === undefined\n});\n```\n\n#### parent\n`.parent()`\n\n###### Description:\nReturns the query's parent element.\n\n###### Sample:\n``` html\n\u003cform\u003e\n\t\u003cfieldset\u003e\n\t\t\t\u003cinput name='email' /\u003e\n\t\u003c/fieldset\u003e\n\u003c/form\u003e\n```\n\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('input[name=email]').parent(); //Returns the Doc object fieldset\n\tdoc('input[name=email]').parent().parent(); //Returns the Doc object form\n});\n```\n\n#### ~~isEmpty~~\n\n###### Description:\n\nThis method is deprecated. Use the method `isPresent()` instead.\n\n#### isPresent\n\n###### Description:\nVerifies if the element exists on the DOM. Returns boolean.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('artile#content').isPresent(); //Return true/false if the element exist\n});\n```\n\n#### checked\n`.checked(value)`\n\n###### Description:\nSet or verify the checkbox or radio field checked state.\n\n###### Parameters:\n\u003e value: boolean //To indicate whether the element should be checked or not\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('input[type=checkbox]').checked(); //Get checked state\n\tdoc('input[type=checkbox]').checked(true); //Set checked state\n});\n```\n\n#### on\n`.on(event, callback [,eventCategory])` or\n`.on(event, callback [, { named: eventCategory, passive: passive } ])`\n\n###### Description:\nAdds an event listener on a Doc object.\n\n###### Parameters:\n\u003e event: String //One or more events that you want to attach to your selector\n\n\u003e callback: Function() //A function to call when the _event_ is triggered\n\n\u003e eventCategory: String //You can add multiple '_events_' of the same type (e.g: _click_) and use the _eventCategory_ parameter to remove certain events when needed. Use _.off()_ to remove the attached handler.\n\n\u003e passive: Boolean // If _true_, indicates that the function specified by listener will never call preventDefault()\n\nPlease note that this method does not work like jquery's .on(). If you append new elements in the page you will have to call .on again on those elements.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('button').on('click', function(){ ... }); //Adds an event listener for the 'click' event\n\tdoc('button').on('click mousemove', function(){ ... }); //Adds event listeners for the 'click' and 'mousemove' event\n\tdoc('button').on('click', function() { ... }, 'tracker'); //Adds a 'click' event listener with the 'tracker' eventCategory\n\tdoc('button').on('click', function() { ... }, { named: 'tracker', passive: true }); //Adds a 'click' event listener with the 'tracker' eventCategory that never call preventDefault()\n});\n```\n\n#### throttle\n`.throttle(event, callback [,timeout] [,eventCategory])`\n\n###### Description:\nPrevents a function from being called multiple times on a set amount of time. Useful to prevent multiple requests.\n\n###### Parameters\n\u003e event: String //The event you want to\n\n\u003e callback: Function() //The function to be called\n\n\u003e timeout: Number //The time in ms you want the application to prevent multiple calls from being made. Default value is 1000.\n\n\u003e eventCategory: You can add multiple '_events_' of the same type (e.g: _click_) and use the _eventCategory_ parameter to prevent one event from being called.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('button').throttle('click', function(){ ... }); //Adds an event listener for the 'click' event.\n\tdoc('button').throttle('click', function(){ ... }, 5000); //Adds an event listener for the 'click' event, preventing other 'click' events to fire within 5 seconds\n\tdoc('button').throttle('click', function(){ ... }, 1000, 'tracker'); //Adds an event listener for the 'click' event with 'tracker' category, aditional clicks will be ignored for 1 second.\n});\n```\n\n#### debounce\n`.debounce(event, callback [,timeout] [,eventCategory])`\n\n###### Description:\nPrevents a function from being called multiple times before a defined amount of time. Useful to prevent multiple requests.\n\n###### Parameters\n\u003e event: String //The event you want to\n\n\u003e callback: Function() //The function to be called\n\n\u003e timeout: Number //The time in ms you want the application to prevent multiple calls from being made. Default value is 1000.\n\n\u003e eventCategory: You can add multiple '_events_' of the same type (e.g: _click_) and use the _eventCategory_ parameter to prevent one event from being called.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('button').debounce('click', function(){ ... }); //Adds an event listener for the 'click' event.\n\tdoc('button').debounce('click', function(){ ... }, 5000); //Adds an event listener for the 'click' event, preventing 'click' events to fire before 5 seconds\n\tdoc('button').debounce('click', function(){ ... }, 1000, 'tracker'); //Adds an event listener for the 'click' event with 'tracker' category, preventing the listener to be called before 1 second.\n});\n```\n\n#### off\n`.off(event [,eventCategory])`\n\n###### Description:\nRemoves the event listener from the Doc object.\n\n###### Parameters:\n\u003e event: String //The event you want to remove from your selector\n\n\u003e eventCategory: String //Removes the attached handler of this category. See _.on()_ for details.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('button').off('click'); //Removes the event listener\n\tdoc('button').off('click', 'tracker'); //Removes the event listener with the 'tracker' eventCategory\n});\n```\n\n#### trigger\n`.trigger(event [, data])`\n\n###### Description:\nDispatches an event that can be listened using `on()`.\n\n###### Parameters:\n\u003e event: String //The event you want to trigger for your selector\n\n\u003e data: Additional data for custom triggered events\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('button').trigger('click'); //Triggers the event click for button.\n});\n```\n\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('button').on('customEvent', function(e) {\n\t\tconsole.log(e.detail.additionalData);\n\t});\n\tdoc('button').trigger('customEvent', { additionalData: \"data\"}); //Triggers the event click for button.\n});\n```\n\n#### selectedText\n`.selectedText()`\n\n###### Description:\nReturns the selected text on a given input field.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('input[name=name]').selectedText() //Returns the selected text of the element.\n});\n```\n\n#### focus\n`.focus()`\n\n###### Description:\nFocus the first matched element\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('input[name=name]').focus() //Focus the first input named \"name\"\n});\n```\n\n#### removeAttr\n`.removeAttr(attrName)`\n\n###### Description:\nRemoves the attribute from the element.\n\n###### Parameters:\n\u003e attrName: String //The name of the element's attribute.\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('div').removeAttr('style'); //Removes style attribute from all divs\n\tdoc('a').removeAttr('href target'); //Removes href and target attribute from all a elements\n});\n```\n\n#### scrollIntoView\n`.scrollIntoView([options])`\n\n###### Description:\nMakes the first element matched by Doc visible at the top of the viewport.\n\n###### Parameters:\n\u003e options: boolean //To indicate whether the element should be aligned to the top of the visible area (default) or to the bottom\n\u003e          object //An object with the properties _block_ (\"start\" or \"end\", indicating the same as the boolean version above) and _behavior_ (\"auto\" or \"instant\" or \"smooth\")\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('div').scrollIntoView(); //Scroll until the first matched div appears at the top of the viewport\n});\n```\n\n#### broadcast\n`doc.broadcast(event [, data])`\n\u003e note: WITHOUT selector\n\n###### Description:\nDispatches a global event that can be listened using `on()` by multiple elements.\n\n###### Important note:\nIf you wish to use this function in IE8, you need to use the `indexOf` polyfill for arrays before usage.\n``` js\nArray.prototype.indexOf||(Array.prototype.indexOf=function(r,t){var n;if(null==this)throw new TypeError('\"this\" is null or not defined');var e=Object(this),i=e.length\u003e\u003e\u003e0;if(0===i)return-1;var a=+t||0;if(Math.abs(a)===1/0\u0026\u0026(a=0),a\u003e=i)return-1;for(n=Math.max(a\u003e=0?a:i-Math.abs(a),0);i\u003en;){if(n in e\u0026\u0026e[n]===r)return n;n++}return-1});\n```\n\n###### Parameters:\n\u003e event: String //The event you want to trigger globally\n\n\u003e data: Additional data for custom triggered events\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('button').on('click', function(e) {\n\t\tconsole.log(e.detail.param);\n\t});\n\tdoc('body').on('click', function(e) {\n\t\tconsole.log(e.detail.param);\n\t});\n\tdoc.broadcast('click', { param: \"I am listening\"}); //Triggers the event click for everybody that listens for the 'onclick' event.\n});\n```\n\n#### insertBefore\n`.insertBefore()`\n\n###### Description:\nInserts an element before each matched element\n\n###### Sample:\n```js\ndefine(['doc'], function(doc) {\n\tdoc('#some-element').insertBefore('a'); //Inserts the element with id some-element before each \u003ca\u003e element\n\n\tvar elements = doc('.before-me');\n\tdoc('#some-element').insertBefore(elements); //Inserts the element with id some-element before elements previously selected with doc-amd\n});\n```\n\n#### insertAfter\n`.insertAfter()`\n\n###### Description:\nInserts an element after each matched element\n\n###### Sample:\n``` js\ndefine(['doc'], function(doc) {\n\tdoc('#some-element').insertAfter(\"a\"); //Inserts the element with id some-element after each \u003ca\u003e element\n\n\tvar elements = doc('.after-me');\n\tdoc('#some-element').insertAfter(elements); //Inserts the element with id some-element after elements previously selected with doc-amd\n});\n```\n\n### Script Commands\n\n|Script|Description|\n|-|-|\n| `npm start` | Start the server. |\n| `npm run start:dev` | Run the start script and then the watch script. |\n| `npm run test` | Run test locally. |\n| `npm run test:ci` | Run the server and the tests. Useful for a quick local check and for CI environment. |\n\n## License\n\nDoc-amd is released under the [BSD](https://github.com/elo7/doc-amd/blob/master/LICENSE). Have at it.\n\n* * *\n\nCopyright :copyright: 2015 Elo7# doc-amd\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felo7%2Fdoc-amd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felo7%2Fdoc-amd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felo7%2Fdoc-amd/lists"}