<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(document).ready({
$('#sh').click(function(){
$('#container').show();
});
});
</script>
<style type="text/css">
#container {
width:350px;
height:350px;
border:1px solid #000000;
display:none;
}
</style>
</head>
<body>
<div id="container">
<p>paragraph 1</p>
</div>
<div>
<a href="#" id="sh">show</a>
</div>
</body>
</html>
clicking on link doesn’t trigger .show() at all!
What am i doing wrong??
Update: i tried $(document).ready({… it doesn’t help!
A few things to keep in mind, load the scripts only after the document has finished loading:
Also, be sure to prevent the default behavior of links when using them to trigger actions:
With these changes, the code works as expected: http://jsfiddle.net/apsje/