onebitrocket
10-19-2009, 11:46 AM
Hi all,
I think i'm in the right part of the forum for this query
I've been working with the slickbox script that is hosted over at learningjquery.com (http://www.learningjquery.com/2006/09/slicker-show-and-hide) to show and hide a div. I am using the toggle function of the.
What i want to happen is when i click on the link to toggle if a div is shown or hidden, that a image swap happens at the same time. So there is a plus.png image to expand the div and a minus.png image to contract the div.
I'm using an if else statement to try and get the images to swap depending on what state the div is currently in. So far I can only get it to swap once but not revert back to it's original state for the second click.
There's an example of what i have so far over at slickbox image swap (http://www.richardheald.com/loadrunnerhtmltest/slickbox.html)
here's the code i have for the function
$('#slick-slidetoggle2').click(function() {
$('#slickbox').slideToggle(1000);
var imageEle = document.getElementById('slick-slidetoggle2');
if(imageEle.innerHTML = '<img src="images/plus.png" width="17" height="17">') {
imageEle.innerHTML = '<img src="images/minus.png" width="17" height="17">';
}
else {
imageEle.innerHTML = '<img src="images/plus.png" width="17" height="17">';
}
return false;
});
Thanks
Matt
I think i'm in the right part of the forum for this query
I've been working with the slickbox script that is hosted over at learningjquery.com (http://www.learningjquery.com/2006/09/slicker-show-and-hide) to show and hide a div. I am using the toggle function of the.
What i want to happen is when i click on the link to toggle if a div is shown or hidden, that a image swap happens at the same time. So there is a plus.png image to expand the div and a minus.png image to contract the div.
I'm using an if else statement to try and get the images to swap depending on what state the div is currently in. So far I can only get it to swap once but not revert back to it's original state for the second click.
There's an example of what i have so far over at slickbox image swap (http://www.richardheald.com/loadrunnerhtmltest/slickbox.html)
here's the code i have for the function
$('#slick-slidetoggle2').click(function() {
$('#slickbox').slideToggle(1000);
var imageEle = document.getElementById('slick-slidetoggle2');
if(imageEle.innerHTML = '<img src="images/plus.png" width="17" height="17">') {
imageEle.innerHTML = '<img src="images/minus.png" width="17" height="17">';
}
else {
imageEle.innerHTML = '<img src="images/plus.png" width="17" height="17">';
}
return false;
});
Thanks
Matt