Re: [jQuery] change img src

2006-10-10 Thread Mika Tuupola

On Oct 10, 2006, at 12:18, Hannah Gray wrote:

 This is probably a very simple question, and I may be going about  
 the problem entirely the wrong way.  Corrections and ideas are very  
 welcome.

Try something like:

-cut-
 $(#toggle_name).toggle(function(e) {
 $('#container_name:visible').hide('slow');
 $('#toggle_name').src('assets/images/expand.gif')
 }, function(e) {
 $('#container_name:hidden').show('slow');
 $('#toggle_name').src('assets/images/retract.gif');
 });
-cut-

-- 
Mika Tuupola
http://www.appelsiini.net/~tuupola/



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] change img src

2006-10-10 Thread Hannah Gray
Thanks for the suggestion.  I was avoiding this option because it assumes the layer is visible in the first place, or, rather, it requires you to hard code the toggle order to match the initial hidden/visible schema. This is part of a much larger CMS and I can't count on the div starting off as visible every time.  See "car name" now for an example of what happens if the layer is hidden via CSS -- the first click of the show/hide icon produces no result.On Oct 10, 2006, at 2:28 AM, Mika Tuupola wrote:     $("#toggle_name").toggle(function(e) {          $('#container_name:visible').hide('slow');          $('#toggle_name').src('assets/images/expand.gif')      }, function(e) {          $('#container_name:hidden').show('slow');          $('#toggle_name').src('assets/images/retract.gif');      }); ___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] change img src

2006-10-10 Thread Christian Bach
Hannah Gray wrote:
 This is probably a very simple question, and I may be going about the 
 problem entirely the wrong way.  Corrections and ideas are very welcome.
 
 Basically, the below code functions to hide and show divs very nicely, 
 but it only changes the image source on hide, not show.

Perhaps something like this?

$('#toggle_year').click(function(){

var layer = $('#container_year);
var icon = this;

if(layer.is(:visible)) {
//hide layer
layer.hide('slow');
//swap icon
icon.src('changeme.gif');
} else {
//show layer
layer.show('slow');
icon.src('changeme');
}   
});

/christian

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/