Created
July 11, 2012 19:18
-
-
Save hcmn/3092548 to your computer and use it in GitHub Desktop.
JQuery UI: addClass
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
#button { | |
background:#f8f8f8; | |
width:100px; | |
padding:3pt; | |
text-align:center; | |
font-weight:bold; | |
-moz-border-radius:3pt; | |
-webkit-border-radius:3pt; | |
border-radius:3pt; | |
border: 2px #EEE solid; | |
} | |
#writing { | |
margin:4pt; | |
text-align:center; | |
height:100px; | |
background:#f8e6d4; | |
} | |
.transition { | |
width: 400px; | |
height: 500px; | |
} |
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
<html> | |
<head> | |
<title>Transitions!</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js" type="text/javascript"></script> | |
<script src="script.js"></script> | |
<link href="addclass.css" rel="stylesheet"/> | |
</head> | |
<body> | |
<div id="button">Change</div> | |
<div id="writing" class=" ui-corner-all">This box changes size when you click that button!</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
$(function() { | |
$( "#button" ).click(function() { | |
// Add the class of 'transition' with the duration | |
// of 1000 and a callback to callbackFunction as | |
// parameters. | |
$('#writing').addClass("transition",1000,callbackFunction); | |
}); | |
function callbackFunction() { | |
setTimeout(function() { | |
// Remove the 'transition' class here | |
$('#writing').removeClass("transition"); | |
}, 1500 ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment