So I am creating this basic image website on php and I am trying to make an image space on each persons profile. I want the image to be maximized (as it currently is) when clicked upon. And then when clicked again it to return to its old position (which it doesn't do). you can see an example here http://www.uk-sf.com/profile.php?view=pgallery:17
but here is the code: below is the img element that is clicked
<img id="1" onclick="clickimage(this)" class="pgall" src="XXX">
then you have the javascript function
function clickimage(id)
{
var y = document.getElementsByClassName('pgall');
var x = document.getElementsByClassName('pgall2');
var length = y.length,
element = null;
for (var i = 0; i < length; i++) {
element = y[i];
element.className = 'pgall';
}
var length = x.length,
element = null;
for (var i = 0; i < length; i++) {
element = x[i];
element.className = 'pgall';
}
id.className = 'pgall2';
}
as you can see currently it will always change what is clicked to my second CSS class "pgall2". What it needs to do is change it too "pgall" if the id.className == "pgall2". However I tried doing this with an if statement and it does not work.
if(id.className == 'pgall')
{
id.className = 'pgall2';
}
else {
id.className = 'pgall';
}