Skip to content

Instantly share code, notes, and snippets.

@drewdeponte
Created December 23, 2010 04:28
Show Gist options
  • Save drewdeponte/752564 to your computer and use it in GitHub Desktop.
Save drewdeponte/752564 to your computer and use it in GitHub Desktop.
A jQuery example that allows the user to test if adding elements past the view height causes jumping to the new element.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Test jQuery Adding Causing Scrolling?</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<style type="text/css" media="screen">
#container {
margin-top: 5px;
border: solid 1px;
padding: 4px;
}
.item {
margin: 4px;
background-color: orange;
height: 20px;
}
</style>
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
$("#add_item_link").click(function () {
$("#container").append('<div class="item"></div>');
return false;
});
});
</script>
</head>
<body>
<p>Testing jQuery Adding Causing Scrolling?</p>
<a id="add_item_link" href="#">Add Item</a>
<div id="container">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment