Jump to content

Jquery show/hide question


DocGrimwig

Recommended Posts

In the following code:

 

<codeblock>

 

<script>
$(document).ready(function(){
$("#hide").click(function(){
$("img").hide();
});
$("#show").click(function(){
$("img").show();
});
});
</script>
</codeblock>
Is my method and syntax correct for hiding an <img>?
Thanks,
Doc
Link to comment
Share on other sites

Yes! that is correct, to show/hide img instantly without delay, else you colud include time period in millseconds $("img").show(2000); to cause it to slowly expand.

 

although $(document).ready(function(){ ...});

 

can be done using shorthand

 

$(function(){...});

 

Also <codeblock>...</codeblock> should be ['code']...['/code'] WITHOUT single quotes

Edited by dsonesuk
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...