Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="querySelector Test">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>querySelector Test</title>
</head>
<body>
  <div class="content">
    <article>
      <h1 class="entry-title">Jonathan</h1>
      <p>Lorem to the ipsum <a href="#">My Site</a>.</p>
    </article>  
  </div>
</body>
</html>
 
// querySelector v other selectors
var queryEl = document.querySelector( '.content article a' ); 
//console.log( queryEl.innerHTML );
// Use the following to replicate the querySelector above
// getElementsByTagName
// getElementsByClassName
var jon1 = document.getElementsByClassName("contnet")[0];
console.log(jon1.innerHTML);
var jon2 = 
jon1.getElementsByTagName("article")[0];
console.log(jon2.innerHTML);
var jon3 = jon2.getElementsByTagName("a")[0];
console.log (jon3.innerHTML);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers