Created
February 6, 2014 19:25
-
-
Save LuisMDeveloper/8850901 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div { | |
background-color: #999; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<p>This is the paragraph 1.</p> | |
<p id="foo">This is the paragraph 2.</p> | |
<p>This is the paragraph 3.</p> | |
<p>This is the paragraph 4.</p> | |
<div> | |
<p>This is the paragraph 5 inside a div.</p> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pElements = document.getElementsByTagName('p'); | |
var lastPelement = pElements[pElements.length - 1]; | |
var pFoo = document.getElementById('foo'); | |
//alert(pFoo); | |
var pElementSel = document.querySelector('p'); | |
//alert(pElementSel.parentNode); | |
var pElementOnDiv = document.querySelector('div p'); | |
//alert(pElementOnDiv); | |
var pFooSel = document.querySelector('#foo'); | |
alert(pFooSel); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment