jquery_selectors_mergez v1.3.8
Purpose
The purpose of this package is to allow users to quickly select and change various elements.
Directions
- Install the package
npm install jquery-selectors-mergez
- In your html document, import the script (make sure to import it after your JQuery script, and before your javascript file)
<script src="./node_modules/jquery_selectors_mergez"></script>
- Create javascript file - make sure to put all your jquery selectors after the instantiator - e.g.,
$(() => {
mergeE.insertAsFirst($("[data-child=1] .grandchild"), $("<div>new Element</div>"))
})
<script src="yourScript.js"></script>
MergeElements
Kind: global class
Date: 2022-02-01
- MergeElements
- new MergeElements()
- .insertAsFirst()
- .wrapEach()
- .addToEndOfNthElement() ⇒ any
- .addToBegOfNthElement() ⇒ any
- .insertBefore() ⇒ any
- .insertAfter() ⇒ any
- .insertAsLast(element, child) ⇒ any
- .findAllFirstOfElement() ⇒ any
- .getAllElementsWithinParent(parent, selector) ⇒ any
- .getAllTextWithinElement() ⇒ any
- .getElementBasedOnSibling() ⇒ any
- .insertAsFirstIntoNthElement() ⇒ any
- .insertAsLastIntoNthElement(nthElement, lastElementInNth) ⇒ any
- .changeParent()
new MergeElements()
a way to insert into elements
mergeElements.insertAsFirst()
mergeE.insertAsFirst($("data-child=1 .grandchild"), newElement)
Kind: instance method of MergeElements
Example
let newElement = $("<div>insert me as first</div>")
mergeE.insertAsFirst($("[data-child=1] .grandchild"), newElement)
mergeElements.wrapEach()
mergeE.wrapEach($(".dropdown > *"), newWrapper)
Kind: instance method of MergeElements
Example
let newWrapper = $("<div class='box'></div>")
mergeE.wrapEach($(".dropdown > *"), newWrapper)
mergeElements.addToEndOfNthElement() ⇒ any
mergeE.addToEndOfNthElement(".dropdown-item", 3, newItem)
Kind: instance method of MergeElements
Date: 2022-02-01
Example
// index works the same as in js, starts with 0
let newItem = $("<div>newdropdown</div>")
mergeE.addToEndOfNthElement(".dropdown-item", 3, newItem)
mergeElements.addToBegOfNthElement() ⇒ any
mergeE.addToBegOfNthElement(".dropdown-item", 3, newItem2)
Kind: instance method of MergeElements
Example
// index works the same as in js, starts with 0
let newItem2 = $("<div>newdropdown</div>")
mergeE.addToBegOfNthElement(".dropdown-item", 3, newItem2)
mergeElements.insertBefore() ⇒ any
Kind: instance method of MergeElements
Date: 2022-02-02
Example
let newDropdown1 = $(`<a href="#" class="dropdown-item" data-id='0'>og0</a>`)
mergeE.insertBefore($("[data-id=1]"), $("<div>insert before other element</div>"))
mergeElements.insertAfter() ⇒ any
let newDropdown = $(<a href="#" class="dropdown-item" data-id='6'>6</a>
)
mergeE.insertAfter($("data-id=5"), $("insert after"))
Kind: instance method of MergeElements
Date: 2022-02-02
mergeElements.insertAsLast(element, child) ⇒ any
insertAsLast($(".parent"), $(".child"))
Kind: instance method of MergeElements
Date: 2022-01-31
Param | Type |
---|---|
element | any |
child | any |
mergeElements.findAllFirstOfElement() ⇒ any
findAllFirstOfElement(parent, first)
Kind: instance method of MergeElements
mergeElements.getAllElementsWithinParent(parent, selector) ⇒ any
mergeE.getAllElementsWithinParent($(".parent"), $(".selectorWithinParent"))
Kind: instance method of MergeElements
Date: 2022-02-06
Param | Type |
---|---|
parent | any |
selector | any |
mergeElements.getAllTextWithinElement() ⇒ any
Kind: instance method of MergeElements
Example
// let getText = mergeE.getAllTextWithinElement("[data-parent='2']")
getAllTextWithinElement(element)
mergeElements.getElementBasedOnSibling() ⇒ any
Kind: instance method of MergeElements
Example
mergeE.getElementBasedOnSibling("[data-greatgrandchild='2']", ".great-grandchild", changeToGreen)
mergeElements.insertAsFirstIntoNthElement() ⇒ any
Kind: instance method of MergeElements
Example
let newLastInsertion2 = $("<div>yoyoas last</div>")
mergeE.insertAsFirstIntoNthElement(".grandchild", 2, $("<div>insert</div>"))
mergeElements.insertAsLastIntoNthElement(nthElement, lastElementInNth) ⇒ any
insertAsLastIntoNthElement(".parent", 2, $("insert"))
Kind: instance method of MergeElements
Date: 2022-01-31
Param | Type |
---|---|
nthElement | any |
lastElementInNth | any |
mergeElements.changeParent()
Kind: instance method of MergeElements
Example
mergeE.changeParent("[data-greatgrandchild='2']", ".parent", changeToPink)
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago