Skip to content

Instantly share code, notes, and snippets.

@atleastimtrying
Last active November 21, 2015 22:35
Show Gist options
  • Save atleastimtrying/655ad1208e8afca60b02 to your computer and use it in GitHub Desktop.
Save atleastimtrying/655ad1208e8afca60b02 to your computer and use it in GitHub Desktop.
An explanation of how paragraph shotgun 2 works!
function(){ //a nice closure to keep our variables nice and tidied away.
for(//a weird looking forloop that does some extra assignment.
var e=document.querySelectorAll("p,li,td,th,h1,span,img,h2,h3,h4,h5"),//grab all of the required elements from the page
i=0,//a count to keep track
l=e.length;//store the length so we don't have to measure again
i<l;// test if we're at the end
++i// increment our counter;
){
e[i].style.cursor="crosshair",//set the style of the current element to crosshair
e[i].addEventListener("click",function(){// listen out for a click on the current element
this.parentNode.removeChild(this)// when clicked find the element's parent and remove the element from it
})// close our click
}// close our loop
}();// close our closure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment