Last active
August 29, 2015 14:23
-
-
Save mbuttler/b45dd4a736a4aadc6fac to your computer and use it in GitHub Desktop.
Matt's jQuery question 6/16
This file contains hidden or 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
// So here's my jQuery script. | |
$(document).ready(function(){ | |
$("#one").after("<p>Awesome funtimes for all!</p>"); | |
$("#two").after($("p")); | |
$("p").remove(); | |
}); | |
//how does it know that by "p" I mean my paragraph? I don't declare it as a variable... | |
// but it still moves it after #two and removes it... why is that? | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Result</title> | |
<script type='text/javascript' src='script.js'></script> | |
</head> | |
<body> | |
<div class="container"> | |
<h2>Greetings</h2> | |
<div id="one">Div #1</div> | |
<div id="two">Div #2</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In jQuery you can use any CSS selectors to select elements, including tag names. When you use
$("p")
it is selecting all p tags on the page.https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started/Selectors