Skip to content

Instantly share code, notes, and snippets.

@dacresni
Created August 6, 2019 14:54
Show Gist options
  • Save dacresni/bdd84793b634354463f20bbdbf475016 to your computer and use it in GitHub Desktop.
Save dacresni/bdd84793b634354463f20bbdbf475016 to your computer and use it in GitHub Desktop.
create islands accordding to a rulee
<script>
var islands = document.querySelectorAll("h3 + ul"); // returns array
islands.forEach(function (child) {
let par = child.parentNode ;
let pre = child.previousElementSibling;
var sec = document.createElement('section');
par.replaceChild(sec,pre);
sec.appendChild(pre);
sec.appendChild(child);
sec.setAttribute("class","standout" );
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment