微件:External demands

来自Hyacinth
草awa留言 | 贡献2024年4月11日 (四) 07:13的版本
跳转到导航 跳转到搜索
<script>
const elements = document.getElementsByClassName('external_demand_span');

const appendTo = document.getElementById('external_demand');

const cats = new Map();

for (let i = 0; i < elements.length; i++) {
    const element = elements[i];
    const clone = element.cloneNode(true);
    console.log(clone.title);
    if (!cats.has(clone.title)) {
    	cats[clone.title] = new Array();
    }
    cats[clone.title].push(clone);
    clone.style.display = 'inline';
    clone.classList.remove('external_demand_span')
}

console.log(cats);

function handler(value, key, map) {
    console.log(key);
    console.log(value);
    const p = document.createElement('p');
    p.innerText = key;
    appendTo.appendChild(p);
    value.forEach((s) => {
        appendTo.appendChild(s);	
    })
}

cats.forEach(handler);

</script>