Created
July 10, 2014 08:49
-
-
Save fatbigbright/d8337e0ccec77ed0db22 to your computer and use it in GitHub Desktop.
Test jQuery to find what selector can do.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>TRY</title> | |
<style> | |
div{ | |
width: 100px; | |
height: 40px; | |
} | |
.blue{ | |
background-color: blue; | |
} | |
.red{ | |
background-color: red; | |
} | |
</style> | |
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> | |
<script> | |
$(document).ready(function(){ | |
$(".test").addClass("blue"); | |
$("#try").click(function(){ | |
$(".test, #div3").removeClass("blue").addClass("red"); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="main"> | |
<div id="div1" class="test"></div> | |
<div id="div2"></div> | |
<div id="div3"></div> | |
<div id="div4"></div> | |
<div id="div5" class="test"></div> | |
<input id="try" type="button" value="TRY"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment