Aug 182009

Usually you can trust the .toggle function (or .slideToggle) to hide or show whatever you want it to. But occasionally you need to know if something is hidden or shown.

var isVisible = $(‘#giftMsg’).is(‘:visible’);
var isHidden = $(‘#giftMsg’).is(‘:hidden’);
Aug 142009

I have defined a click function in the document ready

$(“#submit_request_toggle”).click(function() {

Later, I do an ajax call and I want to be able to redefine the click so that the link doesn’t work anymore (after my ajax call)

type: “POST”,
url: “index.php”,
data: “action=submit_request&first_name=” + $(‘#submit_request_form input[name=first_name]’).val() + “&last_name=” + $(‘#submit_request_form input[name=last_name]’).val() + “&message=” + $(‘#submit_request_form textarea[name=message]’).val(),
success: function(msg){

$(“#submit_request_toggle”).click(function() { return false; });
$(“#submit_request”).fadeOut(500, function() { $(“#submit_request_response”).html(msg).fadeIn(); } );

For some reason, this line:

$(“#submit_request_toggle”).click(function() { return false; });

doesn’t work– the link still shows the hidden div even after I redefine it. Weird.

Jul 202009

Here’s a jQuery function to make your images slightly opaque (or “disabled” looking), then have them fade in when you rollover them.

Just class your <img> tags with imgfade, like this:

<img src=”someimage.jpg” class=”imgfade”>

And put this in <head> declaration:

<script language=”javascript”>
$(“.imgfade”).fadeTo(1, 0.55);
$(this).fadeTo(“500”, 1);
$(this).fadeTo(“500”, 0.55);