<button id="btn">Click</button>
<h1 id="first_H1">First H1 Header</h1>
<p class="first_paragraph">This is my first paragraph.</p>
<p>This is my second paragraph.</p>
<p>This is my third paragraph.</p>
<h1 id="second_H1">First H1 Header</h1>
<p class="first_paragraph">This is my first paragraph.</p>
<p>This is my second paragraph.</p>
<p>This is my third paragraph.</p>
<ul>
<li>First Item</li>
<li>Second Item</li>
<li>Third Item</li>
</ul>
JavaScript
/* Lucille Kenney, Graduate Assignment 4 */
/*
document.addEventListener("mousedown", function(event) {
//console.log("mouse down." + event.clientX + ", y: " + event.clientY);
});
*/
/*var btn = document.getElementById("btn");
btn.addEventListener("mousedown", function(event) {
console.log("mouse down." + event.clientX + ", y: " + event.clientY);
});*/
/*document.addEventListener("mousedown", function(event) {
var els = document.getElementsByClassName("first_paragraph");
for(var i = 0; i < els.length; i++){
console.log(els[i]);
}
});*/
/*document.addEventListener("click", function(event) {
var els = document.getElementsByTagName("li");
for(var i = 0; i < els.length; i++){
console.log(els[i]);
}
});*/
// New jQuery snippets go here:
$(document).on("click", function(event) {
var els = this.querySelectorAll("p.first_paragraph");
for(var i = 0; i < els.length; i++){
console.log(els[i]);
}
});
$(document).on("mousedown", function(event) {
var els = this.getElementsByClassName("first_paragraph");
for(var i = 0; i < els.length; i++){
console.log(els[i]);
}
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.