Jump to content

Big flaw in my image expand/original size toggle script help...


Minimeallolla

Recommended Posts

I have come across a script that sets all images by default to 75x75pixels and clicking toggles between original size and back to 75x75px only problem is each image is in the "a.image-expand img" class. therefor when one image is expanded they all expand.. -.- any way to only expand selected image?

 

$(document).ready(function(){
	// default width and height to 75px
	$("a.image-expand img").css({'height':'75px', 'width':'75px'});

	// Click function (toggle)
	$("a.image-expand").click(function(){
		if(($("a.image-expand img").css("height") == "75px") && ($("a.image-expand img").css("height") == "75px"))
		{
			$("a.image-expand img").css({'height':'auto', 'width':'auto'});
		}
		else
		{
			$("a.image-expand img").css({'height':'75px', 'width':'75px'});
		}
	});
});

Link to comment
Share on other sites

Here is the working script if anybody ever wants it.  (all codes shown are vital for a working code)

 


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

<a class="image-expand" style="cursor: pointer" onclick="toggleSize(this)">
	<img src="Pics/roflcopter.gif" />

$(document).ready(function(){
	// default width and height to 75px
	$("a.image-expand img").css({'height':'75px', 'width':'75px'});
});

function toggleSize(_var_)
{
	image = $(_var_).children("img");

	if(($(image).css("height") == "75px") && ($(image).css("height") == "75px"))
	{
		$(image).css({'height':'auto', 'width':'auto'});
	}
	else
	{
		$(image).css({'height':'75px', 'width':'75px'});
	}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.