jQuery UI Example - Show
Use custom effects to show matched elements.
For more details about the .show()
method, please refer to the API documentation .show().
.show() Demonstration
Click the button to preview the effect.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Effects - .show() Demonstration</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
<style>
.toggler { width: 500px; height: 200px; }
#button { padding: .5em 1em; text-decoration: none; }
#effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
#effect h3 { margin: 0; padding: 0.4em; text-align: center; }
</style>
<script>
$(function() {
// Run the currently selected effect
function runEffect() {
// Get the effect type from the select menu
var selectedEffect = $( "#effectTypes" ).val();
// Most effect types do not need options
var options = {};
// Some effects have required parameters
if ( selectedEffect === "scale" ) {
options = { percent: 100 };
} else if ( selectedEffect === "size" ) {
options = { to: { width: 280, height: 185 } };
}
// Run the effect
$( "#effect" ).show( selectedEffect, options, 500, callback );
};
// Callback function
function callback() {
setTimeout(function() {
$( "#effect:visible" ).removeAttr( "style" ).fadeOut();
}, 1000 );
};
// Set effect based on menu value
$( "#button" ).click(function() {
runEffect();
return false;
});
$( "#effect" ).hide();
});
</script>
</head>
<body>
<div class="toggler">
<div id="effect" class="ui-widget-content ui-corner-all">
<h3 class="ui-widget-header ui-corner-all">Show</h3>
<p>
Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede. Nulla lorem metus, adipiscing ut, luctus sed, hendrerit vitae, mi.
</p>
</div>
</div>
<select name="effects" id="effectTypes">
<option value="blind">Blind Effect</option>
<option value="bounce">Bounce Effect</option>
<option value="clip">Clip Effect</option>
<option value="drop">Drop Effect</option>
<option value="explode">Explode Effect</option>
<option value="fold">Fold Effect</option>
<option value="highlight">Highlight Effect</option>
<option value="puff">Puff Effect</option>
<option value="pulsate">Pulsate Effect</option>
<option value="scale">Scale Effect</option>
<option value="shake">Shake Effect</option>
<option value="size">Size Effect</option>
<option value="slide">Slide Effect</option>
</select>
<a href="#" id="button" class="ui-state-default ui-corner-all">Run Effect</a>
</body>
</html>