jQuery - Toggle Image Expand/Close
I have a dashboard pretty much a rip off of BBC.com which allows you to minimise and and expand the widget by clicking on a butt开发者_如何学Con.
When you've clicked on it, the image changes to indicate the widget is expanded or minimized.
Does anyone know how to do this in jQuery?
Take a look here
Example:
$('.target').toggle();
If you want something to slide up and down you can try this:
var visible = true;
$("button").click(function () {
$("p").slideToggle("slow", function () {
visible = !visible;
if (visible)
{
$('icon').attr('src', 'url_to_downimage.jpg');
}
else
{
$('icon').attr('src', 'url_to_expandimage.jpg');
}
});
});
精彩评论