jQuery for Beginners

< Back to blog | Add a comment

Posted: 23rd Nov 2009
Categories: Tips and Tricks Web Development
Tags: jquery beginners demo

Following my article on Woorkup, I thought I'd just post a working demo of what I wrote about - a basic jQuery form fade.

Copy and paste the code below in to your website, and it should work! I have also put a working demo below as well.

<script src="http://code.jquery.com/jquery-latest.pack.js" type="text/javascript"></script>

<script type="text/javascript">
$(function(){
    $('.showform').click(function(event){
        event.preventDefault();
        $('#mydiv').fadeIn();
    });
});
</script>

<!--Start of container div, and form-->

<div id="mydiv" style="display:none;">
    <form id="myform" action="wherever.php" method="post">
        <input name="myinput" type="text" />
        <input type="submit" value="Submit" />
    </form>
</div>

<p>To show the form <a class="showform" href="/mylink.php">click here</a>.</p>

<!-- End of form and container div -->

To show the form click here.

Comments

By ewrsagf on 25th Jan 2010

nice!

Add a comment









Back to top