added tag26
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
@@ -105,6 +105,34 @@
|
||||
// Capacity: 11 oz.
|
||||
|
||||
// Füge den Listenpunkt aber dieses Mal nicht am Ende der Liste ein, sondern vor dem Eintrag Materials: Ceramic.
|
||||
const list = $('#product_specification');
|
||||
const item5 = $$('#product_specification li')[4];
|
||||
// const listItem5 = $('#product_specification li:nth-child(5)');
|
||||
// const listItem5 = $('#product_specification').lastElementChild.previousElementSibling; // DOM Traversal
|
||||
|
||||
console.log(item5);
|
||||
|
||||
const newList = document.createElement('li');
|
||||
newList.textContent = 'Capacity: 11 oz.';
|
||||
|
||||
list.insertBefore(newList, item5);
|
||||
|
||||
// ======================
|
||||
|
||||
const prodSpecEl = $('#product_specification');
|
||||
const prodSpecLiEls = $$('#product_specification li');
|
||||
|
||||
// einzufügenden Listenpunkt erstellen
|
||||
const liCapacity = document.createElement('li');
|
||||
liCapacity.textContent = 'Capacity: 11 oz.';
|
||||
|
||||
// Nu suchen an welcher Stelle - also den listenpunkt mit dem text Materials: Ceramic
|
||||
const refLi = prodSpecLiEls.find((el) => {
|
||||
return el.textContent === 'Materials: Ceramic';
|
||||
});
|
||||
|
||||
// und einfügen
|
||||
prodSpecEl.insertBefore(liCapacity, refLi);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user